Simple Invoice, Gmail/Google Apps, SMTP and PHP

Using Gmail as an SMTP server can be a pain if you don’t know what you are looking for.  Fortunately, there are some decent tutorials online that can get you there….more or less.

I just wanted to recap my experience when trying to use Google Apps as my SMTP server when setting up Simple Invoice…..

1) Get the latest PHPMailer from http://phpmailer.worxware.com/.  Install accordingly.

2) Compile OpenSSL for PHP.  If on windows simply delete the semi-colon (;) in front of ;extension=php_openssl.dll in php.ini

3) When making calls to phpmailer, the host should be ssl://smtp.gmail.com, the port should 465, username should be your full email address and of course your password.   If the phpmailer version requires the input, SMPT_AUTH should be true.

That should be it.

For those using Simple Invoice, you can set your config.ini file to look like this:

email.host = ‘ssl://smtp.gmail.com’
email.smtp_auth = true
email.username =  test@gmail.com
email.password =  password
email.smtpport = 465
email.secure       =
email.ack     = true

Hope that helps someone.  If you have any questions, just comment and I’ll get back with you.

Advertisements

4 Comments (+add yours?)

  1. Paul McCrodden
    Dec 10, 2010 @ 01:17:30

    Hi senica,

    Thanks for the tip, had no luck though I’m afraid. Only ‘difference’ is I’m using Google Apps Gmail. Using:

    email.host = ‘ssl://smtp.gmail.com’
    email.smtp_auth = true
    email.username = info@paulmccrodden.com
    email.password = password
    email.smtpport = 465
    email.secure =
    email.ack = true

    I get “Zend Mail Protocol Exception: is unsupported SSL type”

    Using:

    email.host = ‘ssl://smtp.gmail.com’
    email.smtp_auth = true
    email.username = info@paulmccrodden.com
    email.password = password
    email.smtpport = 465
    email.secure = ssl
    email.ack = true

    I get “Zend Mail Protocol Exception: ”ssl://smtp.gmail.com” appears to be a DNS hostname but cannot match TLD against known list, ”ssl://smtp.gmail.com” does not appear to be a valid local network name”

    and using:

    email.host = smtp.gmail.com
    email.smtp_auth = true
    email.username = info@paulmccrodden.com
    email.password = password
    email.smtpport = 465
    email.secure = ssl
    email.ack = true

    I get “Zend Mail Protocol Exception: Connection timed out”.

    I might post there on the Forum for support, but thanks to the alternative methods to try seeing as they work for you.

    ~mccrodp

  2. senica
    Dec 10, 2010 @ 11:22:46

    Hey Paul,
    Well, this isn’t going to be much help but I’m pretty sure that Google Apps uses the same settings as Gmail: http://mail.google.com/support/bin/answer.py?hl=en&answer=78799

    It does say that is requires TLS….I’m pretty sure that is a valid setting in PHPMailer.

    Are you setting this up on your computer or on a hosted domain?

  3. Paul McCrodden
    Dec 10, 2010 @ 13:03:47

    Cheers, yep that’s the official support resource for this issue, I hadn’t see thanks, but yea, I had tried all combinations of those config options, ports, security, acks, etc. Seems to time out with all those correct input params, anything else gives me a more manageable error. Tried putting E_ALL on, but nothing useful from it.

    I’m using it on a hosted domain, contacted them (hostgator) and I have phpmailer set-up with tls and ssl, so I dunno, quite hard to debug this one, don’t know if it’s timing out at Gmails servers or mine.

    Thanks anyway for your help, much appreciated, if you think of anything else I could do to try and debug the above let me know. I may also hear back on the Simple Invoice forum here: http://www.simpleinvoices.org/forum/discussion/1307/p1

    ~mccrodp

  4. rolandc
    Mar 08, 2012 @ 14:48:06

    hi, it did help, thanks a lot for the the tip. Now i can’t really understand why so many tutorials on the net still feature tips on how to send fake sendmail email from wamp stations. As far as i’m concerned i can’t really imagine situations where devs would be forced to use php’s inbuilt mail() function over phpmailer. Now even using php’s built-in mail function it is still possible to use google apps accounts along with ssl, only php.ini needs a little editing and it works well. Having said all that, to me, the most challenge with mail sending is not to be able to send, but to be able to send to everyone and not get banned from remote mail servers… One step at a time, thanks for this tutorial)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: