As I am using Amazon Lightsail and the port 25 is blocked by the provider, so I wanted to use port 587 to send email and use the emailing through my web app.

My /etc/postfix/master.cf looks like this...

# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (no)    (never) (100)
# ==========================================================================

submission inet n       -       n       -       -       smtpd
  -o syslog_name=postfix/submission
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject

I think it's actually listening the port 587

netstat -na | grep LISTEN | grep 587
tcp        0      0 *               LISTEN     
tcp6       0      0 ::1:587                 :::*                    LISTEN

but... It's not sending email through the desired port 587

I tried sending a test email with this command...

echo "This is the body of the email" | mail -s "This is the subject line" myproperemail@gmail.com

But /var/log/mail.log is saying something else...

Aug  6 00:54:44 deviser postfix/qmgr[765647]: 770F01B68AC: from=<ubuntu@deviser.club>, size=378, nrcpt=1 (queue active)
Aug  6 00:54:44 deviser postfix/error[765966]: 770F01B68AC: to=<myproperemail@gmail.com>, relay=none, delay=575, delays=575/0.01/0/0.01, dsn=4.4.1, status=deferred (delivery temporarily suspended: connect to alt2.gmail-smtp-in.l.google.com[2a00:1450:4013:c16::1a]:25: Connection timed out)

  • 2
    1. You can't just "change port to send at will". Most servers don't accept mail from other server on port 587 (smtp submission). They only accept mail this way from authenticated clients who are their customers. At best you can configure to use smarthost, but you need to somebody run a smarthost for you. Please look at Postfix SOHO readme. 2. Where your server is listening is completely irrelevant for outgoing connections. Better shutdown that submission agent for security, if you aren't planning to accept mail from MUAs like Thunderbird. Aug 6 at 3:03
  • Just going to point out that AWS does block port 25 outbound by default. But you can make a very simple request to have it opened. As mentioned, email exchanged on the internet between MTAs uses port 25. aws.amazon.com/premiumsupport/knowledge-center/… . This applies to everything in a VPC. It is an account wide setting if I remember correctly. Aug 6 at 13:48


Your Answer

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

Browse other questions tagged or ask your own question.