0

I configured Postfix using this guide. When I send a test E-Mail I get the following error message:

May 23 15:36:26 VM11 postfix/smtp[15321]: connect to smtp.gmail.com[2a00:1450:4001:c02::6d]:587: Network is unreachable
May 23 15:36:26 VM11 postfix/smtp[15321]: 4AA58243A3: to=<root@VM11.rbg.informatik.tu-darmstadt.de>, relay=smtp.gmail.com[173.194.70.108]:587, delay=0.07, delays=0.01/0/0.04/0.02, dsn=5.7.0, status=bounced (host smtp.gmail.com[173.194.70.108] said: 530 5.7.0 Must issue a STARTTLS command first. y10sm16916731eev.3 - gsmtp (in reply to MAIL FROM command))
May 23 15:36:26 VM11 postfix/qmgr[15314]: 4AA58243A3: removed

I configured my authentication data:

[stmp.gmail.com]:587 USER@GOOGLEDOMAIN:PASSWORD

And what follows is my general configuration main.cf:

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = VM11.rbg.informatik.tu-darmstadt.de
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = 
relayhost = [smtp.gmail.com]:587
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 51200000
recipient_delimiter = +
inet_interfaces = loopback-only
inet_protocols = all

# Further authentication stuff
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_password
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_tls_auth_only = no

So what is wrong with the configuration?

EDIT: Based on Andrzej A. Filip's suggestion I changed smtpd_use_tls=yes to smtp_use_tls. This now leaves me with another error message:

May 26 11:20:36 VM11 postfix/smtp[20031]: D9982243B9: to=<root@VM11.rbg.informatik.tu-darmstadt.de>, relay=smtp.gmail.com[173.194.70.108]:587, delay=0.19, delays=0.02/0/0.15/0.01, dsn=5.5.1, status=bounced (host smtp.gmail.com[173.194.70.108] said: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 z52sm34463651eea.1 - gsmtp (in reply to MAIL FROM command))

I double checked my sasl_password file and postmaped it again without any success.

Bastian
  • 95
  • 2
  • 4
  • 13

3 Answers3

2

The recipe mentions smtp_use_tls but you have set smtpd_use_tls.

http://mhawthorne.net/posts/postfix-configuring-gmail-as-relay.html Troubleshooting / 1. No TLS

AnFi
  • 5,883
  • 1
  • 12
  • 26
  • Ok I changed the line and am now facing an authentication failure. Please have a look at my edited description above. – Bastian May 26 '13 at 09:31
2

Try the following modified version that worked for me in Ubuntu 18.04 (assuming starting from scratch, replace vi with nano or whatever editor you are familiar with):

Complete these steps as root.

  1. apt-get install postfix mailutils libsasl2-2 ca-certificates libsasl2-modules
    Note: Choose "internet site" and other default options if promted with questions in terminal. Run dpkg-reconfigure postfix if you need to reconfigure postfix over.
  2. Create your password file with vi /etc/postfix/sasl_passwd
  3. Populate the password file. Example: [smtp.gmail.com]:587 myusername@gmail.com:mypassword
  4. Secure the file by running chmod 600 /etc/postfix/sasl_passwd
  5. Replace the contents of the config file by running vi /etc/postfix/main.cf
  6. Place the following in the file:

    relayhost = [smtp.gmail.com]:587
    smtp_use_tls = yes
    smtp_sasl_auth_enable = yes
    smtp_sasl_security_options =
    smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
    smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
    
  7. Encode password file by running postmap /etc/postfix/sasl_passwd

  8. Restart postfix service by running systemctl restart postfix.service

  9. Replace you@example.com with your email in the following code and test sending mail: echo "Test mail from postfix" | mail -s "Test Postfix" you@example.com

  10. Give google a min to process. You should see the sent mail in your sent folder for your gmail account and in the inbox of the specified destination account. If the mail doesn't come, check cat /var/mail/root, cat /var/log/mail.log or other places depending on your distribution for errors.

1

In addition to Andrzej A. Filip's observation the password file contained a spelling error:

stmp.gmail.com should actually be smtp.gmail.com

Bastian
  • 95
  • 2
  • 4
  • 13