This article explains how to setup XAMPP to send emails over the Gmail smtp server using the PHP-function mail().
Softwares:
ProjectPier 0.8.0.2 (http://downloads.sourceforge.net/projectpier/projectpier-0.8.0.2.zip)
XAMPP for Windows Version 1.6.6 (http://www.apachefriends.org/download.php?xampp-win32-1.6.6a.zip)
stunnel Version 4.21 (http://www.stunnel.org/download/stunnel/win32/stunnel-4.21-installer.exe)
Requirements:
Enable POP for your Gmail account (http://mail.google.com/support/bin/answer.py?answer=13273)
Port 465 (or 587) must be opened to the internet (http://www.portforward.com/english/routers/port_forwarding/routerindex.htm)
Short explanation.
The smtp servers of Gmail require SSL authentication. This provides a way of authentication and encryption between your XAMPP server and the Gmail smtp servers. This is not supported by default in XAMPP. I will explain how this can be added with use of the SSL program "stunnel".
Step 1: Follow the directions of http://www.projectpier.org/manual/installation/xampp to install your working ProjectPier.
Step 2: Install stunnel-4.21-installer.exe on your XAMPP server. Then, open the stunnel configuration file (usually "C:\Program Files\stunnel\stunnel.conf").
Here is my stunnel.conf:
cert = stunnel.pem
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1
debug = 7
output = stunnel.log
client = yes
[smtpg]
accept = 127.0.0.1:25
connect = smtp.gmail.com:465
;or connect = 72.14.215.109:465 so there's no DNS lookup
Save these lines to your own stunnel configuration file. Now, stunnel can be started (Start - Programs - stunnel - Run stunnel).
Step 3: Configure your php.ini file. XAMPP has three php.ini files, look in your XAMPP welcome screen and cick on "phpinfo()". There you will find the location of the php.ini file which needs to be changed (mine is at C:\xampp\apache\bin).
Here is my php.ini entry for the mail function:
[mail function]
; For Win32 only.
sendmail_path = "C:\xampp\sendmail\sendmail.exe -t"
SMTP = localhost
smtp_port = 25
Save the changes to your php.ini and STOP-START THE XAMPP SERVER!
Step 4: Configure sendmail.ini. The XAMPP installation contains sendmail. You will find a folder "sendmail" in your XAMPP folder.
Here is my c:\xampp\sendmail\sendmail.ini entry for the mail function:
[sendmail]
smtp_server=localhost
smtp_port=25
default_domain=gmail.com
error_logfile=error.log
auth_username=[yourgmailname]@gmail.com
auth_password=[yourgmailpassword]
You should have a working sendmail functionality using Gmail's smtp-servers now!
Step 5: Configure ProjectPier to send email.
In ProjectPier, open the mail configuration: » Dashboard » Administration » Configuration » Mailing and just make sure to set "Mail transport" to "Default PHP settings" (you don't need to set any server-, port- or authentication settings, because this will be handled by the PHP function)
You should now be able to use ProjectPier to send an email to yourself! (» Dashboard » Administration » Tools » Test mail settings)
In short: ProjectPier will generate the email messages and hand these over to PHP's sendmail function (configured in step 5). PHP will run the sendmail.exe to send outgoing email messages (configured in step 3) and Sendmail is configured to send the email messages from the localhost, using default smtp port 25 with username and password for the smtp server (configured in step 4). All traffic for port 25 on the localhost will be recognised by stunnel. Stunnel is configured to handle this traffic and send it out on port 465 using SSL which Gmail uses for the smtp servers (configured in step 2).
I advise to try the above exactly as I have described. First make everything work and when you have it working, then you might want to take care to configure XAMPP and stunnel as services. Use the instructions on the XAMPP and stunnel webpages to get this done..