Php – sendmail on Snow Leopard

gmailosx-snow-leopardPHPsendmail

I'm trying to get sendmail working on my MacBook Pro (OS 10.6.4), so that I can send mail with PHP's mail() function. If you know how to do this without sendmail, I'd be interested in that also.

The plan is to send mail through smtp.gmail.com using my gmail account, unless you have a better idea.

I did this and that didn't work.
In /etc/postfix/smtp_sasl_passwords I tried both:
    smtp.yourisp.com username:password
and
    smtp.yourisp.com username@gmail.com:password

The problem seems to be that google doesn't like me. I don't think my ISP is blocking it because Mail.app can send email through smtp.gmail.com just fine.

$email is my gmail address.

$ printf "Subject: TestMail" | sendmail -f $email $email
$ tail /var/log/mail.log
Oct 21 19:38:18 Jays-MacBook-Pro postfix/master[8741]: daemon started -- version 2.5.5, configuration /etc/postfix
Oct 21 19:38:18 Jays-MacBook-Pro postfix/qmgr[8743]: CAACBFA905: from=<$email>, size=377, nrcpt=1 (queue active)
Oct 21 19:38:18 Jays-MacBook-Pro postfix/pickup[8742]: C2A68FA93A: uid=501 from=<$email>
Oct 21 19:38:18 Jays-MacBook-Pro postfix/cleanup[8744]: C2A68FA93A: message-id=<20101021233818.$mydomain>
Oct 21 19:38:18 Jays-MacBook-Pro postfix/qmgr[8743]: C2A68FA93A: from=<$email>, size=377, nrcpt=1 (queue active)
Oct 21 19:38:18 Jays-MacBook-Pro postfix/smtp[8746]: initializing the client-side TLS engine
Oct 21 19:38:18 Jays-MacBook-Pro postfix/smtp[8748]: initializing the client-side TLS engine
Oct 21 19:38:49 Jays-MacBook-Pro postfix/smtp[8746]: connect to smtp.gmail.com[74.125.157.109]:25: Operation timed out
Oct 21 19:38:49 Jays-MacBook-Pro postfix/smtp[8748]: connect to smtp.gmail.com[74.125.157.109]:25: Operation timed out
Oct 21 19:38:49 Jays-MacBook-Pro postfix/smtp[8746]: CAACBFA905: to=<$email>, relay=none, delay=1334, delays=1304/0.04/30/0, dsn=4.4.1, status=deferred (connect to smtp.gmail.com[74.125.157.109]:25: Operation timed out)
Oct 21 19:38:49 Jays-MacBook-Pro postfix/smtp[8748]: C2A68FA93A: to=<$email>, relay=none, delay=30, delays=0.08/0.05/30/0, dsn=4.4.1, status=deferred (connect to smtp.gmail.com[74.125.157.109]:25: Operation timed out)
$

I also tried setting myhostname, mydomain, and myorigin in /etc/postfix/main.cf to
$ nslookup myip
(as displayed by http://www.whatismyip.com/)

And still no luck.

Any ideas?

Best Answer

Can you telnet to smtp.gmail.com port 25 ? (If you can, type QUIT to close the connection). If you can't your ISP is probably blocking port 25, and you should try port 587 for submitting your mail.

relay_host=[smtp.google.com]:587