Link to home
Start Free TrialLog in
Avatar of kgp43
kgp43Flag for Denmark

asked on

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

Avatar of kgp43
kgp43
Flag of Denmark image

ASKER

Or can it be a server issue, not allowing me to send the form data to an external email account?
Avatar of Meir Rivkin
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?
Avatar of kgp43

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kgp43

ASKER

It works fine now, must be an issue with the helpdesk settings (zendesk).
Thanks for your help :)
no problem, good luck.