• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 276
  • Last Modified:

Can't send email

Hi,

I have a weird problem.

I use the following function to send emails from my support form on my website, but it simply stopped working, no email is being received in my helpdesk from this form.

Have tried to send and email manually from my private email account to the same "receiver/helpdesk email" and it works fine.

So I wonder, is there an error in this coding (I removed the parameters for error checking)?
# Send email to contact
function contact() {

	$name = "Kenneth";
	$email = "my@email.com";
	$title = "A message";
	$message = "The message";

	# Send the email
	if(mail("mail@domain.com", $title, $message, "From: $name <$email>\nX-Mailer: PHP/" . phpversion())) {
		
		return true;
	}else{
	
		return false;
	}
}

Open in new window

0
kgp43
Asked:
kgp43
  • 3
  • 3
1 Solution
 
kgp43Author Commented:
Or can it be a server issue, not allowing me to send the form data to an external email account?
0
 
Meir RivkinFull stack Software EngineerCommented:
try this:
$name = "Kenneth";
	$email = "my@email.com";
	$title = "A message";
	$message = "The message";

	
$headers = "From: $name <$email>\r\nX-Mailer: PHP/".phpversion();

	# Send the email
	if(mail("mail@domain.com", $title, $message, $headers)) {

		return true;
	}else{
	
		return false;
	}
}

Open in new window


btw, are you using gmail address as sender?
also you might get filtered, is this your server? are you using paid mail server/host?
0
 
kgp43Author Commented:
Hi,

I't's not gmail. My own domain and own server.
The helpdesk settings etc are setup correctly (I can receive emails from all my private email accounts).

I will try what you suggested.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Meir RivkinFull stack Software EngineerCommented:
If firewall is enabled, check that firewall not filter the ports used to send the mail.
also check if your server has MTA (mail transfer agent) installed (windows based server doesn't have it as default)
0
 
kgp43Author Commented:
It works fine now, must be an issue with the helpdesk settings (zendesk).
Thanks for your help :)
0
 
Meir RivkinFull stack Software EngineerCommented:
no problem, good luck.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now