My ISP requires that mail from my dynamic IP to our small business email addresses uses their outgoing SMTP servers. This is probably done to reduce abuse and spam but now I’m not able to send email and local Postfix log file displays authentication failure message. How do I relay mail through my mail ISP servers using Postfix SMTP under Linux / UNIX like operating systems?
Postfix has a method of authentication using SASL. It can use a text file or MySQL table as a special password database.
Configure SMTP AUTH for mail servers
Create a text file as follows:
# P=/etc/postfix/password
# vi $P
The format of the client password file is as follows:
#smtp.isp.com username:password smtp.vsnl.in vivek@vsnl.in:mySecretePassword
Save and close the file. Set permissions:
# chown root:root $P
# chmod 0600 $P
# postmap hash:$P
Enable SMTP AUTH
Open main.cf file, enter:
# vi /etc/postfix/main.cf
Append following config directives:
relayhost = smtp.vsnl.in smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/password smtp_sasl_security_options =
Where,
- relayhost = smtp.vsnl.in : Rely all mail via smtp.vsnl.in ISP mail server.
- smtp_sasl_auth_enable = yes : Cyrus-SASL support for authentication of mail servers.
- smtp_sasl_password_maps = hash:/etc/postfix/password : Set path to sasl_passwd.
- smtp_sasl_security_options = : Finally, allow Postfix to use anonymous and plaintext authentication by leaving it empty.
Save and close the file. Restart Postfix:
# /etc/init.d/postfix reload
Test your setup by sending a text email:
$ echo 'This is a test.' > /tmp/test
$ mail -s 'Test' you@example.com
🐧 30 comments so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Hi,
I tried the configuration but getting the following error log
this site is technicaly helpful.
Vivek,
I have no other words than praising you. :) I am very glad that you are from India :)
This is the 3rd or 4th comment by me on your site.
Keep Rocking dude.. :)
we3cares,
Thanks for feedback!
How can I add multiple users in the /etc/postfix/password……..?
I was tried like these
[smtp.gmail.com]:587 test@gmail.com:test
[smtp.gmail.com]:587 linux@gmail.com:linux
…… So on
But it was not accept those patter……
Can you please help me how can i add multiple users…..are waiting for reply?
Please scrap me or mail me this is my email id: krisuresh001@gmail.com
Try this FAQ.
Thank you for taking the time to write the tutorial, I had tried everything else with no luck – but this worked!!
Thanks
I need help in setting up a postfix server. I am getting a lot of Yahoo 421 errors. Please email me on dchatpar@gmail.com or call me on 9004642799
Dhiraj Kumar –> go to hell.
Hi. Thanks for the site – very helpful! I am having a problem, however: mail leaves my Linux box but keeps getting rejected by the ISP. I did a TCPDUMP on it and here’s what I see:
Sorry,.that.domain.isn’t.in.my.list.of.allowed.rcpthosts…503.You.must.send.RCPT.TO:.first..
I’ve tried every setting I can think of in main.cf. Can you please offer advice?
Thanks
Mike
it doesn’t work. if you try to send mail to example@mydomain.com where mydomain.com is hosted on the same server via dns server, but zone file points to internal MX servers for example if you using google apps. so it tryes to put the mail on same server via local transport because IP is one, because it is THE SAME SERVER. so this issue totally not actual sometimes.
nice how to but i have to solve this thing too:
=4.7.0, status=deferred (SASL authentication failed; cannot authenticate to server smtp.isp.com [xx.xx.xx.xx]: no mechanism available)
Excellent tutorial. I searched high and low for something like this. Thank you very much.
yakup
=4.7.0, status=deferred (SASL authentication failed; cannot authenticate to server smtp.isp.com [xx.xx.xx.xx]: no mechanism available)
I have fixed this installing cyrus-sasl-plain in my centos.
Saved my day. Thank you
That did the trick! Thanks for the tip on installing cyrus-sasl-plain!!!!!!
Saved mine too! Thanks for actually posting the fix!
@ itamar … awsome bro , your comment saved me !!
[Soleved] cannot authenticate to server / no mechanism available
Have a fix if you are still having SASL errors, check that all the modules are loaded. For me on CentOS:
yum install cyrus-sasl cyrus-sasl-lib cyrus-sasl-plain
Feb 9 22:04:14 localhost postfix/smtp[3226]: 87EEAC7D1A: to=, relay=smtp.isp.net[1.2.3.4]:587, delay=2.7, delays=0.18/0.2/2.4/0, dsn=4.7.0, status=deferred (SASL authentication failed; cannot authenticate to server smtp.isp.net[1.2.3.4]: no mechanism available)
what if you don’t need authentication i get this even though the server does not need authentication.
relay=smtp.mweb.co.za[196.28.80.20]:25, delay=0.68, delays=0.19/0.02/0.35/0.12, dsn=5.0.0, status=bounced (host smtp.mweb.co.za[196.28.80.20] said: 550-Verification failed for 550-Unrouteable address 550 Sender address rejected: Sending user unknown (in reply to RCPT TO command))
Hi Vivek,
Postfix is installed default on my RHEL 6.2 system. I am able to send mail to gmail, yahoo. But when I try to send mail to my office mail ID. it is not working. Do I need to do anything on server side.
Seeing the following error in logs..
status=sent (250 Message Queued (Timeout Verifying RCPTs);
Thanks,
Chittu
i have postfix installed on centos 6.4. but i can’t receive email from yahoo or more. postfix status=bounced said: 550 5.0.0 … User unknown (in reply to RCPT TO command) is the error. Please help me
Hi,
I searched for a long time until I could find out how to run mail from a cmd line and connect to a remote mail system (google) using authentication.
It is almost working, but not quite. Looks like I need to start tls first. Could you tell me how to reconfigure for that.
here are the logs:
Hi again,
Oops – just realized I specified port 587 which uses TLS which requires certificates which is way more complex than I need.
I tried using (specifying) port 465 which postfix said was unimplemented.. and to use TLS. I defulated back to no port, but the connection just times out.
Any suggestions??
Here is my log showing my port 465 attemp followed by no port specified.. and 25 gets used…
thanks
Bob
Hi ,
i have configured tls in postfix as relay host , but while sending mails using openssl i am getting below error , i am not sure this error related to my postfix error or client side relay server issue .
test.mail.com postfix/smtp[56450]: DD26420E05: to=, relay=smtp.postfix.com.com[10.3.41.12]:587, delay=24, delays=21/0.05/2.1/0.25, dsn=4.7.0, status=deferred (host smtp.postfix.com.com[10.3.41.12] said: 403 4.7.0 Authentication required (in reply to MAIL FROM command))
that does not answer the question. the poster asked how to support multiple accounts on the SAME mailserver.
Read Postfix Configure Multiple ISP Client SMTP Authentication.
This isn’t working for me.
I have systems users, they need to be able to auth as plain or login, no ssl/tls, no mysql surely someone has made a simple configuration that work.
Please give me a plug and play solution, if you try to teach me why it doesn’t work we will go no where as I need it up immediatley, can learn after it’s working from the working solution.
Dear Sir,
I am facing an issue with IMAP-proxy server.
as per my findings SMTP is responding to mobile outgoing server.
we can receive mail on mobiles but unable to sent.
outlook with the same credentials is working fine, i have restarted postfix,imap,nginx services but problem not resolved.
may be authentication is working properly between smtp or mobiles.
please help me on this…
regards
ashish
I got it working with no problem when sending mail from the terminal on the server. I then tried to send from another computer on my network using port 25. I kept getting the error:
NOQUEUE: reject: RCPT from unknown[xxx.xxx.xxx.xxx]: 450 4.7.0 : Recipient address rejected: defer_if_permit requested; from= to= proto=ESMTP helo=
where xxx.xxx.xxx.xxx = IP address of sending PC.
I did a bunch of searching and did the following to get it to work:
First I made a password file in /etc/postfix containing:
#smtp.isp.com username:password
smtp.MyISP.com MyEmail@MyISP.com:MyEmailPassword
Be sure to set access/ownership correctly with:
# chown root:root /etc/postfix/password
# chmod 0600 /etc/postfix/password
# postmap hash:/etc/postfix/password
Then I added the following to my main.cf file:
# My server IP is: 192.168.0.152