Solved

Can't send email

Posted on 2013-01-26
6
267 Views
Last Modified: 2013-01-27
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
Comment
Question by:kgp43
  • 3
  • 3
6 Comments
 

Author Comment

by:kgp43
ID: 38823601
Or can it be a server issue, not allowing me to send the form data to an external email account?
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 38823616
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
 

Author Comment

by:kgp43
ID: 38823623
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 38823627
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
 

Author Comment

by:kgp43
ID: 38823628
It works fine now, must be an issue with the helpdesk settings (zendesk).
Thanks for your help :)
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 38823629
no problem, good luck.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question