Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sendmail/postfix mail not sending from local Mac OS X (Mountain Lion)

Tags:

email

macos

I'm trying to get sendmail/postfix working properly on my iMac (10.9.2). I have a php web application I'm trying to test locally and it needs to send mail.

Even when testing this directly:

date | mail -s test [email protected]

The mail never arrives, even as spam. In the logs, I'm seeing tons of "operation timed out" errors for contacting google/gmail:

Mar 17 10:57:13 imac.helion3.com postfix/postfix-script[10924]: starting the Postfix mail system
Mar 17 10:57:13 imac.helion3.com postfix/master[10925]: daemon started -- version 2.9.4, configuration /etc/postfix
Mar 17 10:57:13 imac.helion3.com postfix/qmgr[10933]: 012175629F9F: from=<[email protected]>, size=352, nrcpt=1 (queue active)
Mar 17 10:57:16 imac.helion3.com postfix/pickup[10932]: 94BBF562A0B2: uid=501 from=<botskonet>
Mar 17 10:57:16 imac.helion3.com postfix/cleanup[10948]: 94BBF562A0B2: message-id=<20140317175716.94BBF562A0B2@localhost>
Mar 17 10:57:16 imac.helion3.com postfix/qmgr[10933]: 94BBF562A0B2: from=<[email protected]>, size=310, nrcpt=1 (queue active)
Mar 17 10:57:43 imac.helion3.com postfix/smtp[10937]: connect to gmail-smtp-in.l.google.com[74.125.25.27]:25: Operation timed out
Mar 17 10:57:46 imac.helion3.com postfix/smtp[10951]: connect to gmail-smtp-in.l.google.com[74.125.25.26]:25: Operation timed out
Mar 17 10:58:13 imac.helion3.com postfix/smtp[10937]: connect to alt1.gmail-smtp-in.l.google.com[74.125.193.27]:25: Operation timed out
Mar 17 10:58:16 imac.helion3.com postfix/smtp[10951]: connect to alt1.gmail-smtp-in.l.google.com[74.125.193.27]:25: Operation timed out
Mar 17 10:58:43 imac.helion3.com postfix/smtp[10937]: connect to alt2.gmail-smtp-in.l.google.com[74.125.196.26]:25: Operation timed out
Mar 17 10:58:46 imac.helion3.com postfix/smtp[10951]: connect to alt2.gmail-smtp-in.l.google.com[74.125.196.27]:25: Operation timed out
Mar 17 10:59:13 imac.helion3.com postfix/smtp[10937]: connect to alt3.gmail-smtp-in.l.google.com[173.194.76.27]:25: Operation timed out
Mar 17 10:59:16 imac.helion3.com postfix/smtp[10951]: connect to alt3.gmail-smtp-in.l.google.com[74.125.29.26]:25: Operation timed out
Mar 17 10:59:43 imac.helion3.com postfix/smtp[10937]: connect to alt4.gmail-smtp-in.l.google.com[74.125.131.27]:25: Operation timed out
Mar 17 10:59:43 imac.helion3.com postfix/smtp[10937]: 012175629F9F: to=<[email protected]>, relay=none, delay=689, delays=538/0.01/150/0, dsn=4.4.1, status=deferred (connect to alt4.gmail-smtp-in.l.google.com[74.125.131.27]:25: Operation timed out)
Mar 17 10:59:46 imac.helion3.com postfix/smtp[10951]: connect to alt4.gmail-smtp-in.l.google.com[173.194.75.27]:25: Operation timed out

I've run through the recommended postfix perms commands:

sudo mkdir -p /Library/Server/Mail/Data/spool
sudo /usr/sbin/postfix set-permissions
sudo /usr/sbin/postfix start

I've configured postfix to use ipv4 after seeing ipv6 errors in the logs. This is for testing something locally anyway so I don't mind.

I've configured php to use:

sendmail_path=/usr/sbin/sendmail -t -i

Even though my current tests don't involve php.

like image 815
helion3 Avatar asked Mar 17 '14 18:03

helion3


1 Answers

It appears port 25 is blocked (either from your ISP or possibly on your end):

google.com[74.125.131.27]:25: Operation timed out

Open Terminal and paste:

(echo >/dev/tcp/localhost/25) &>/dev/null && echo "TCP port 25 opened" || echo "TCP port 25 closed"

This should indicate whether or not port 25 is opened on your machine. If the port is closed you'll obviously need to open it.

Another useful command is:

sudo lsof -i -P | grep -i "listen"

Which will indicate all of the open ports and connections currently active.

Since you haven't provided any info about your configuration itself I can only speculate what your relayhost is set as. If it's google, then try setting the port to 587:

relayhost = smtp.gmail.com:587

Often ISP's block port 25 by default since it's commonly used by spammers.

EDIT: It was determined that two things had to be taken into consideration for this scenario:

  1. The postfix mailserver was using a dynamic ip
  2. The mailserver is hosted with an ISP that blocks port 25

The fix was to use a relay server, which involved updating the postfix main.cf with the additions of the relay host information and authentication flags. The default submission port was changed to use 587 to bypass the isp block.

like image 182
l'L'l Avatar answered Sep 19 '22 20:09

l'L'l