Welcome Guest, Not a member yet? Register   Sign In
Outgoing SMTP/TLS email via Google on Ubuntu/Debian platforms
#1

[eluser]Douglas Clifton[/eluser]
After several frustrating hours attempting to get the Email Class to send secure/authenticated mail via port 587 through smtp.google.com I finally threw in the towel. On that approach anyway, as usual there is easier way to do it. So, share the love as they say...

Recall that PHP typically sends outgoing mail via /usr/sbin/sendmail when you use the built-in mail() function. On most Debian-based systems, like Ubuntu, sendmail is just a wrapper around the the real Exim4 MTA. The trick is to configure Exim to route outgoing messages through Google, but keep in mind that if you use this method all email will be sent this way.

Follow the clear instructions found at these two articles:

* Ubuntu 8.0.4 Hardy Gmail Smarthost setup with Exim4
* Using Exim4 to send Messages through GMail

Once you restart your MTA daemon you can confirm this works from a shell:

Code:
$ /usr/sbin/sendmail -ti
To: [email protected]
From: [email protected]
Subject: Test

Test...
^d
$

Check "somone"s inbox, you should get a message via Google. You can also watch the exim log:

Code:
$ tail /var/log/exim4/mainlog

To check for errors/success.

Then, to send email via PHP/CodeIgniter, just use the PHP mail() function:

Code:
$to = '[email protected]';
$from = 'From: [email protected]';
$subject = 'Test';
$message =<<<_M
This is me, is that you?
_M;

if (mail($to, $subject, $message, $from)) {
    echo 'No errors from mail()!';
}

Works for me.

Of course, if you want to do something fancy like sending HTML mail (yuck) or attachments, you're going to have to do some more work.

I'm running Ubuntu/8.04 LTS, PHP/5.2.4 and CodeIgniter/1.7.0, your setup may very well vary. ~d
#2

[eluser]hybriid[/eluser]
This might be of help. I'm currently using it on Ubuntu Intrepid.

http://ellislab.com/forums/viewthread/84689/
#3

[eluser]Douglas Clifton[/eluser]
Yeah, I read that thread while I was researching this topic. The approach I took was the only one I could get to work, and I sort of like using the built-ins when I can. Classes are nice and all, but they introduce overhead. It should work for you under Intrepid as well.
#4

[eluser]gullah[/eluser]
Thank you so much. This saved me a few hours of work and headache no doubt.




Theme © iAndrew 2016 - Forum software by © MyBB