I am trying to set-up Postfix on my Ubuntu local web development machine for send-only e-mails using Gmail so I can test e-mails sent by a web app I am developing.

These are the steps I have followed based on a recently posted tutorial found here:

  1. Dowloaded and installed Postfix using "Internet Site" option
    The FQDN I am using is 'lhdwlamb.com'. This also appears in /etc/hosts . Excerpts of the configuration file where specified edits are needed:

    myhostname = daniel-wsT7500
    alias_maps = hash:/etc/aliases
    alias_database = hash:/etc/aliases
    myorigin = /etc/mailname
    mydestination = $myhostname, lhdwlamb.com, daniel-wsT7500, localhost.localdomain, loc$
    relayhost = [smtp.gmail.com]:587
    mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
    mailbox_size_limit = 0
    recipient_delimiter = +
    inet_interfaces = all
    inet_protocols = all

    #Enable SASL authentication
    smtp_sasl_auth_enable = yes
    smtp_sasl_security_options = noanonymous
    smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
    smtp_tls_security_level = encrypt
    smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt

  2. Obtained a Google App Password
    This is a step I found missing from several other tutorials I found. For Google account settings 2-step verification is on when using Google App password. I have also tried the old method of my regular gmail password with allow less secure apps turned on.

  3. Created as sasl_passwd file

    [smtp.gmail.com]:587 xxxxxxx@gmail.com:xxxxxxxxxxxx

(x's replace actual values for security here)

  1. The sasl_passwd file is converted to a db using sudo postmap

  2. Files sasl_passwd and sasl_passwd.db changed to root and 0600 as listed:

    ll /etc/postfix/sasl/
    total 12
    -rw------- 1 root root 55 Jan 31 17:06 sasl_passwd
    -rw------- 1 root root 12288 Jan 31 17:09 sasl_passwd.db

  3. Postfix was restarted using sudo systemctl restart postfix.

Test e-mails are not receiving by GMail. This is the result I am seeing in mail.log (xxx's for security here):

Jan 31 16:39:51 daniel-wsT7500 postfix/smtp[28260]: E8545E1313: to=<xxxxxxx@gmail.com>, relay=smtp.gmail.com[173.194.205.108]:587, delay=67, delays=65/0.12/1.4/0, dsn=4.7.8, status=deferred (SASL authentication failed; server smtp.gmail.com[173.194.205.108] said: 535-5.7.8 Username and Password not accepted. Learn more at?535 5.7.8  https://support.google.com/mail/?p=BadCredentials o5sm12089476qko.85 - gsmtp)

I have looked at the page for the link in that error message and not found anything to help with this problem.

Can anyone help with information I am missing or other problems to test for?

Thanks for taking the time to read this.

Recommended Answers

All 4 Replies

@rproffitt

Tried the tutorial you suggested. No joy. I have tried several tutorials aside from the one mentioned in my original post. I cited that one for it was the most recent and the only to mention a Google App password which I think is important given how Google has tightened credentials that use its products like Grive for Google Drive, postfix, etc.

Yes, the GMAIL setup is both onerous and not optional. I don't recall if any tutorial covered that so here's Google about how to enable the relay service. https://support.google.com/a/answer/2956491?hl=en

To be clear, this is not a full fledged email server but a relay system.

I am trying to set-up Postfix on my Ubuntu local web development machine for send-only e-mails using Gmail so I can test e-mails sent by a web app I am developing.

Even though this is an old post I wanted to reply as I found it while trying to setup my own postfix mailrelay on my private cloud server with Debian that hosts our small homepage with a contact form.

I've been struggeling with Postfix for several days and came to hate it a bit. I read a ton of forum posts and blogs and never got it to work correctly - the config is just to annoying.

Finally I asked in IRC and was recommended to check out OpenSMTPD - this mail server, which can be used as a simple mailrelay too, is MUCH more easy to configure.

I was recommended to read this excellent blogpost on how to set it up for exactly the purpose of relaying emails from a web application to large mail providers like gmail, which then deliver the mail. I got it working after 45 minutes and the blogpost explained every little detail in the config files.

Never again will I touch postfix :P Hope it helps the next person here too.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.