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[]: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 []:587 this would work. Any idea how to switch this?

Thanks in advance!

| improve this question | | | | |
  • Your ISP is blocking you from connecting to other sites port 25. You would somehow have to get every mail server that you want to connect to to listen on port 587. Good luck with that. – Paul Tomblin Oct 17 '10 at 14:46
  • I only need to connect to one mail server (google) that listens on 587. I just need to know how to switch over to that port. – Jeff Oct 17 '10 at 14:51
  • I don't see any reason why an ISP should block port 25 specifically. But as far as Gmail goes, their SMTP server listens on port 587 and that is why you get a timeout on port 25. – Meher Oct 17 '10 at 14:53
  • Meher- Exactly! So how do I switch to port 587? – Jeff Oct 17 '10 at 14:58
  • Gmail’s servers that receive mail from the outside world do not listen on port 587. Only their outgoing servers, for authenticated Gmail users, listen on 587. Are you trying to use Gmail as our outbound SMTP server, or are you trying to send mail to a Gmail user? – Nate Oct 17 '10 at 15:00

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:

| improve this answer | | | | |
  • Right. In google's case, the server does listen on 587. I just need to know how to switch ports in postfix. – Jeff Oct 17 '10 at 14:58
  • aspmx.l.google.com does not listen on port 587. Maybe you are thinking of smtp.gmail.com? – Nate Oct 17 '10 at 15:02
  • you're right ... I'm thinking of smtp.gmail.com – Jeff Oct 17 '10 at 15:03
  • Thanks Nate. I'll take a swing at this. Also, this may sound strange but how do I switch the server I'm connecting to? Is there some sort of configuration file for postfix? I can't seem to find how it's choosing to connect to google's server. Strange I know but I must've somehow set this somewhere. – Jeff Oct 17 '10 at 15:23
  • I’ve added a note about the relayhost parameter. – Nate Oct 17 '10 at 15:27

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.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.