Kurinchi Blogger Scribbles …


Jun 15
2012

How to Send Emails from your local WAMP XAMPP server in windows?

Last updated: June 23rd, 2012

… a question that raises in the mind of programmers developing applications in their local development environments.

This can be achieved by making the following modifications.

Step (i) Install the WAMP / XAMPP server in your windows machine. After this install you will be able to access sites created on the localhost with URL http://localhost

Step (ii) Download and extract the send mail application for Windows from http://glob.com.au/sendmail/. Remember the path where you have extracted sendmail. For e.g. c:\wamp\sendmail

Step (iii) Edit sendmail.ini within c:\wamp\sendmail. This ini file has enough documentation explaining how the configuration changes should happen on the file.

Check through the following list of parameters to make sure correct values are set

smtp_server=mail.sampledomain.com
smtp_port = 25 (check the mail server’s port number to make sure that you set the correct port)
auth_username=username@sampledomain.com
auth_password=userpassword

Step (iv) Edit PHP.ini file

Next step is to change the php.ini native to the installation . Search for the string “sendmail_path”

Set this path to the folder where send mail installed

sendmail_path = “c:\sendmail\sendmail.exe -t -i”

Step (v) PHP Email program to send email

$mailFrom = "user1@domain.com";
$mailto = "toyouremail@test.com";
$mailsubject = "Test eMail";
$mailbody = "Test send mail program from WAMP. It is cool.";

$mailHeaders = 'From: '.$mailFrom."\r\n" .
'Reply-To: '.$mailFrom. "\r\n" .
'MIME-Version: 1.0' . "\r\n" .
'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

if (mail($mailto, $mailsubject, $mailbody, $mailHeaders)) {
echo("Email successfully sent!!");
} else {
echo("Email delivery failed!!!");
}

To send email using Google Mail server, there is slight variation in step (iii)

Step (iii) Edit sendmail.ini within c:\wamp\sendmail. This ini file has enough documentation explaining how the configuration changes should happen on the file.

Check through the following list of parameters to make sure correct values are set

smtp_server=smtp.gmail.com
smtp_port=465
smtp_ssl=ssl
default_domain=localhost
error_logfile=error.log
debug_logfile=debug.log
auth_username=myname@gmail.com
auth_password=my_gmail_password
pop3_server=
pop3_username=
pop3_password=
force_sender=
force_recipient=
hostname=localhost

Note: Log into myname@gmail.com email account and check in Account Settings under "Forwarding and POP/IMAP" for IMAP access and "Enable IMAP" access.

In the WAMP Server, we need to enable
a) Apache module - ssl_module
b) PHP extensions - php_openssl, php_sockets

Restart WAMP server and execute the php program to send out emails.

Tags: , , , , , , , , , , ,

2 Responses to “How to Send Emails from your local WAMP XAMPP server in windows?”

  1. Chad says:

    I followed your steps exactly but am still getting a, “Could not instantiate mail function” error. Any ideas? Thanks

  2. Chad says:

    Do I have to edit the original php.ini file in these locations too?

    [mail function]
    ; For Win32 only.
    ; http://php.net/smtp
    SMTP =
    ; http://php.net/smtp-port
    smtp_port = 25

    ; For Win32 only.
    ; http://php.net/sendmail-from
    sendmail_from = you@domain.com

Leave a Reply


Valid HTML 4.01 Strict  Valid HTML 4.01 Strict