43

I've been trying to configure email to forward to Gmail, using Postfix to relay email to smtp.gmail.com. However, I'm failing to get it to authenticate with smtp.gmail.com, which is a rather vital prerequisite to getting anything working…

The mail logs show only:

Oct 29 15:50:14 gsnedders-1 postfix/master[6596]: daemon started -- version 2.7.1, configuration /etc/postfix
Oct 29 15:50:19 gsnedders-1 postfix/pickup[6598]: EBA1F78750: uid=1000 from=<gsnedders>
Oct 29 15:50:19 gsnedders-1 postfix/cleanup[6603]: EBA1F78750: message-id=<20111029145019.EBA1F78750@mail.gsnedders.com>
Oct 29 15:50:19 gsnedders-1 postfix/qmgr[6599]: EBA1F78750: from=<gsnedders@gsnedders.com>, size=324, nrcpt=1 (queue active)
Oct 29 15:50:19 gsnedders-1 postfix/cleanup[6603]: F2D557874F: message-id=<20111029145019.EBA1F78750@mail.gsnedders.com>
Oct 29 15:50:19 gsnedders-1 postfix/local[6605]: EBA1F78750: to=<me@gsnedders.com>, orig_to=<me>, relay=local, delay=0.04, delays=0.03/0.02/0/0, dsn=2.0.0, status=sent (forwarded as F2D557874F)
Oct 29 15:50:19 gsnedders-1 postfix/qmgr[6599]: F2D557874F: from=<gsnedders@gsnedders.com>, size=454, nrcpt=1 (queue active)
Oct 29 15:50:19 gsnedders-1 postfix/qmgr[6599]: EBA1F78750: removed
Oct 29 15:50:20 gsnedders-1 postfix/smtp[6606]: warning: SASL authentication failure: No worthy mechs found
Oct 29 15:50:20 gsnedders-1 postfix/smtp[6606]: F2D557874F: SASL authentication failed; cannot authenticate to server smtp.gmail.com[74.125.157.108]: no mechanism available

And the postfix config is:

relayhost = [smtp.gmail.com]:587

smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl/passwd
smtp_sasl_security_options = noanonymous

smtp_tls_eccert_file =
smtp_tls_eckey_file =
smtp_tls_security_level = may
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtpd_tls_received_header = yes
tls_random_source = dev:/dev/urandom
smtpd_tls_security_level = may
gsnedders
  • 1,191
  • 1
  • 8
  • 8
  • 1
    First modify the following line in `/etc/postfix/master.cf`: `smtp unix - - y - - smtp -v`, so you can get more details in the log. – Jaime Hablutzel Aug 08 '18 at 04:50

5 Answers5

66

Ah-ha! Installing the libsasl2-modules package solved the problem.

gsnedders
  • 1,191
  • 1
  • 8
  • 8
36

Running

sudo yum install cyrus-sasl cyrus-sasl-lib cyrus-sasl-plain
sudo systemctl restart postfix

helped me on Amazon AWS server (and CentOS/RHEL 8).

qris
  • 1,203
  • 12
  • 21
Aldekein
  • 491
  • 4
  • 6
  • Also helps with Postfix on Fedora 27 (there you have to replace yum with dnf, of course) - also with other SMTP relays that do plain authentication over TLS. Just installing postfix doesn't pull in the cyrus-sasl-plain package ... (this changed from Fedora 26). – maxschlepzig Apr 03 '18 at 08:51
  • Work on CentOS 7 + Postfix – Trần Hữu Hiền Dec 23 '22 at 09:23
4

sudo yum install cyrus-sasl cyrus-sasl-lib cyrus-sasl-plain

worked for me with Gmail relay setup (CentOS 7)

pla
  • 41
  • 1
2

I was getting this issue(tail -f /var/log/mailog):

to=<usmanali@example.com>, relay=smtp.sendgrid.net[169.45.113.201]:587, delay=0.3, delays=0.05/0.07/0.16/0.02, dsn=5.0.0, status=bounced (host smtp.sendgrid.net[169.45.113.201] said: 550 Unauthenticated senders not allowed (in reply to MAIL FROM command))

Then i changed file /etc/postfix/main.cf in this way that added following lines into end of file

mtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination
mailbox_size_limit = 256000000

# Sendgrid Settings
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = static:apikey:SG.YOUR_SENDGRID_KEY
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = may
header_size_limit = 4096000
relayhost = [smtp.sendgrid.net]:587

Then Installing postfix missing module dependency using:

sudo yum install cyrus-sasl cyrus-sasl-lib cyrus-sasl-plain

Then restarting postfix

sudo systemctl restart  postfix.service

Finally it works on centos 7

Usman Ali Maan
  • 232
  • 1
  • 7
1

Setting up following environment variable worked for me:

SASL_PATH=/usr/lib/x86_64-linux-gnu/sasl2

(this is for Ubuntu).

kenlukas
  • 3,101
  • 2
  • 16
  • 26
R K
  • 11
  • 1