Sending Mail in Xampp

I have literally spent hours trying to set up mail on my localhost so that I can send test emails from Magento, and finally its working. So I thought I would share my solution in case it saves others wasted hours too :)

Firstly I needed to download the most recent release of sendmail. This can be found here: http://glob.com.au/sendmail/. Once downloaded browse to c:/xampp/sendmail (assuming your installation is on your c:/ drive) and delete and replace with the newly downloaded files.

Then in c:/xampp/sendmail/sendmail.ini comment everything out but the following lines and modify to be your own email address and password.

smtp_server=smtp.gmail.com
smtp_port=25
error_logfile=error.log
debug_logfile=debug.log
auth_username=youremail@gmail.com
auth_password=yourgmailpassword
force_sender=youremail@gmail.com

Then in c:/xampp/php/php.ini search for “mail” and comment out everything but sendmail_path and mail.add_x_header lines.

; For Win32 only.
; http://php.net/smtp
;SMTP = localhost
; http://php.net/smtp-port
;smtp_port = 25
 
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = postmaster@localhost
 
; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
 
; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =
 
; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = Off
 
; Log all mail() calls including the full path of the script, line #, to address and headers
;mail.log = "C:\xampp\apache\logs\php_mail.log"

Then restart Apache and it should work!!
To test you can place this script in your htdocs change the $to field and browse to it.

<?php
$to = "youremail@email.com";
$subject = "Test Email";
$message = "Testing mail is working";
 
if(mail($to,$subject,$message)){
echo "sent";
}else{
echo "failed";
}?>

Thank you to http://stackoverflow.com/questions/4948687/xampp-sendmail-using-gmail-account for pointing me in the right direction :)

Comments

Be the first to write a comment about Sending Mail in Xampp…

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>