Friday, January 28, 2011

Sending emails with postfix via port 587 on gmail

Since my ISP blocks port 25 I'd like to be able to configure postfix to send smtp email over port 587. Every time I try to send an email I see this in the mail.log

Oct 17 10:37:49 new-host-2 postfix/smtp[1552]: connect to aspmx.l.google.com[74.125.113.27]:25: Operation timed out

I'm assuming this is due to the fact that this doesn't work over port 25. What do I need to modify in order to get smtp to communicate over port 587? I tried using port forwarding but that wasn't working either.

Not sure but I think if I can get the mail.log to show [74.125.113.27]:587 this would work. Any idea how to switch this?

Thanks in advance!

  • In order for you to send mail on port 587, the server on the other end needs to be listening on port 587, which it probably isn't.

    If your provider blocks outgoing port 25 (and many residential ISPs do; those that don't should, it's simply a good practice) then you will need to configure Postfix to send all outgoing mail to your ISP's mail server for delivery.

    In most cases, you can set the following in your postfix main.cf to relay all mail to your ISP's mail server:

    relayhost = mail.your-isp.com
    

    See also the postfix documentation.

  • Most mail servers do not listen on port 587. Those that do, usually designate that as a port for authenticated users only, to relay mail. They generally do not accept incoming e-mail from the outside world on port 587.

    Edit: It seems like you are trying to use Gmail as an outbound SMTP server. In this case you need to:

    1. Connect to smtp.gmail.com, not the aspmx.* servers, which are for inbound mail.
    2. Tell Postfix to connect to the outbound server on port 587 using TLS encryption.
    3. Tell Postfix to AUTH (authenticate) the connection using your Gmail username and password.

    Edit #2: Here is an all-in-one example: http://www.bamweb.nl/computer/linux/271

    Other documentation:

    Nate : `aspmx.l.google.com` does not listen on port 587. Maybe you are thinking of `smtp.gmail.com`?
    Nate : I’ve added a note about the `relayhost` parameter.
    From Nate

0 comments:

Post a Comment