Sendmail using Gmail SMTP server to send emails from ProjectPier

Tagged:  

I want to express my gratitude to the ProjectPier developers and to this community. I have not contributed much to this project until now. I have struggled very much with the "Notifier has failed to construct mailer object" message and finally got it solved. I will try to document my working config here..

I will explain how I have 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..

nJoy!

You just solved the exact same problem I had with Wamp Server. Except Wamp server doesn't come with sendmail. So I had to download and isntall it, which is very simple.

Thank You!

For those of you who use wamp server, you can download sendmail here:
http://glob.com.au/sendmail/

Just extract the zip file into folder called sendmail, and place it your wamp directory. Then follow the above directions and vwalla.

Thanks for this how-to. It worked a treat for me when I was having no luck sending mail.

Cheers!

I've followed all of these instructions and although my projectpier is saying message sending is a success, (and my phpbb3 is saying messages are sending) no messages ever arrive in my gmail account.

However, when I disable sendmail and just use stunnel, it will connect to google but I get [phpBB Debug] PHP Notice: in file /includes/functions_messenger.php on line 410: mail() [function.mail]: SMTP server response: 530-5.5.1 Authentication Required. Learn more at
530 5.5.1 http://mail.google.com/support/bin/answer.py?answer=14257 l37sm9313006waf.23

How do I tell stunnel my authentication (username and password) ?

HI ALL,
I am followed instuctions as above and i got as mail was success ,but i did not any mail in gmail inbox.pls help me,i am strugling a lot since lot of time for doing this application,moreover i am running this application from my company network,is it reason for failure of program(unable to receive mail in to gmal inbox).here is code for my php script.

Untitled Document

<?
// Please specify your Mail Server - Example: mail.yourdomain.com.
//ini_set("SMTP","131.127.167.78");

// Please specify an SMTP Number 25 and 8889 are valid SMTP Ports.
//ini_set("smtp_port","25");

// Please specify the return address to use
//ini_set('sendmail_from', 'Ramesh.Naga@Honeywell.com');

// The message
$message = "All the best";
$headers = 'From:ram.cdac87@gmail.com';
// In case any of our lines are larger than 70 characters, we should use wordwrap()
//$message = wordwrap($message, 70);

// Send

$i=mail('Ram.cdac87@gmail.com', 'My Subject', $message,$headers);
if($i)
echo "sucess";
else
echo "sorry";
?>

I created new gmail address for use with ProjectPier.
It works perfectly with test mail settings but when I create a new account, system response user with these:
Note: I use a same email address for testing and creating new account.

----------------
With reference to your message with the subject:
"Your account has been created"

The local mail transport system has reported the following problems
it encountered while trying to deliver your message:

-------------------------------------------------------------------
*** [USER_NAME] <[EMAIL_ADDRESS]
555 5.5.2 Syntax error. 21sm1475891pxi.0
-------------------------------------------------------------------

Your mail message is being returned to you in the next part of this
message.

Should you need assistance, please mail postmaster@localhost.
---------------------

I've tried for several email addresses and get the same result.
Any idea?

Thank you and best regards,

Ahh - finally sending mail from my localhost.

Thank you. Thank you. Thank you.