Xampp Send Email Issues

After upgrading my xampp installation I had issues sending email.

I wrote a small test PHP page and it was saying my emails were being sent, but I never received them. Obviously something was misconfigured.

I thought I correctly edited my php.ini file, but it turns out all the tinkering I did with it may have caused the issues.

Search your php.ini file for [mail function].

  1. Remove the comment on smtp and smtp_port by removing the semi colons before them.
  2. Add smtp server, port number. I’m using my ISP smtp server. Find your ISP smtp settings by searching google.
  3. sendmail_from needs to be set only if you don’t specify a from header in your PHP code. This can be set to any email address.
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
SMTP = examplesmtpserver.com
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = email you want to send from (ex: [email protected]). This needs to be set or a from header must be added in the php mail code

 

Here is test PHP code that I used. You’ll have to edit the “to” variable to your email address.

$to = "your email here";
$subject = "Test Email";
$body = "Email for testing Xampp";

if (mail($to, $subject, $body)){
	echo("Message successfully sent!");
} 
else{
	echo("Message delivery failed…");
}

After visiting your created PHP page the page should tell you whether PHP sent your email. Please note that just because PHP says it sent the mail doesn’t actually mean the email will be delivered  While I was having issues PHP still said it successfully sent, but I wasn’t receiving emails. If you’re still having problems after it says email successfully sent you’ll have to do more digging.

Contact me if you have questions I’ll do my best to assist [email protected].

 

 

Share this Story
Load More Related Articles
Load More By Nick Escobedo
Load More In How-To's

Check Also

PHP Enums in 60 Seconds

Learn the basics of PHP enums in 60 ...