Linux – Postfix not sending authentication when relaying to local smtp server

emaillinuxpostfixsmtpUbuntu

I have been trying to get my postfix server to relay all of my message to a local SMTP server. As far as I can tell I have everything set up right, but I get a 550 Authentication error. My local SMTP server works fine when i send a message with something like send mail, just not when I relay a message using postfix. ( I changed my credentials/relay host name)

Here is my main.cf file

# See /usr/share/postfix/main.cf.dist for a commented, more complete version
debug_peer_list = 127.0.0.1
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
append_dot_mydomain = no
readme_directory = no
myhostname = evconnect.info
alias_maps = hash:/etc/aliases
virtual_alias_maps = hash:/etc/postfix/virtual
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = localhost
mynetworks = 0.0.0.0/0 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
local_recipient_maps =
relay_domains=*
recipient_delimiter = +
inet_interfaces = all
transport_maps = hash:/etc/postfix/transport

smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/saslpasswd
smtp_always_send_ehlo = yes
relayhost = [localhost]:587

inet_protocols = all

Here is my /etc/postfix/saslpasswd file prehash.

[localhost]:587      user:password
localhost            user:password

Here is the mail log when trying to send a message to my relayhost

Jan 14 16:20:51 ip-10-251-110-190 postfix/smtp[5056]: 9A01B24436: to= 
<driver8lpqh2mrx@host.info>, relay=host.info[xx.xxx.xxx.xxx]:587, delay=0.69, 
delays=0.2/0.01/0.48/0, dsn=5.0.0, status=bounced (host host.info[xx.xxx.xxx.xxx] said: 550  
Authentication required (in reply to MAIL FROM command))

Log from raalyhost (Haraka smtp server):

[NOTICE] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] connect ip=54.184.245.135 port=44974 
local_ip=:: local_port=587
[DEBUG] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] running lookup_rdns hooks
[DEBUG] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] running connect hooks
[DEBUG] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] running connect hook in dnsbl plugin
[DEBUG] [-] [dnsbl] looking up: 135.245.184.54.zen.spamhaus.org.
[DEBUG] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] hook=connect plugin=dnsbl function=connect_first params="" retval=CONT msg=""
[DEBUG] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] running connect hook in max_unrecognized_commands plugin
[DEBUG] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] hook=connect plugin=max_unrecognized_commands function=hook_connect params="" retval=CONT msg=""
[PROTOCOL] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] S: 220 ip-10-251-110-190 ESMTP Haraka 2.5.0 ready
[PROTOCOL] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] C: EHLO evconnect.info state=1
[DEBUG] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] running ehlo hooks
[DEBUG] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] running capabilities hooks
[PROTOCOL] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] S: 250-ip-10-251-110-190 Hello ec2-54-184-245-135.us-west-2.compute.amazonaws.com [54.184.245.135], Haraka is at your service.
[PROTOCOL] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] S: 250-PIPELINING
[PROTOCOL] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] S: 250-8BITMIME
[PROTOCOL] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] S: 250 SIZE 500000
[PROTOCOL] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] C: MAIL FROM:<> SIZE=5035 state=1
[PROTOCOL] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] S: 550 Authentication required
[PROTOCOL] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] C: RCPT TO:<DoNotReply@evconnect.com> state=1
[PROTOCOL] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] S: 503 Use MAIL before RCPT
[PROTOCOL] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] C: DATA state=1
[PROTOCOL] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] S: 503 MAIL required first
[PROTOCOL] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] C: RSET state=1
[DEBUG] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] running rset hooks
[PROTOCOL] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] S: 250 OK
[PROTOCOL] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] C: QUIT state=1
[DEBUG] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] running quit hooks
[PROTOCOL] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] S: 221 ip-10-251-110-190 closing connection.          Have a jolly good day.
[DEBUG] [A0BFEE28-79CE-4719-B23A-05B9990AA397] [core] running disconnect hooks

Log when sending emails using swaks(it works)

=== Trying localhost:587...
=== Connected to localhost.
<-  220 ip-10-251-110-190 ESMTP Haraka 2.5.0 ready
 -> EHLO host.com
<-  250-ip-10-251-110-190 Hello Unknown [127.0.0.1], Haraka is at your service.
<-  250-PIPELINING
<-  250-8BITMIME
<-  250-SIZE 500000
<-  250 AUTH LOGIN CRAM-MD5
-> AUTH CRAM-MD5
<-  334 PGVhMTUwLjE0YWU5NjQ4YjE4QGlwLTEwLTI1MS0xMTAtMTkwPg==
-> ZXZjYWRtaW4gNDU3NDMxOTE0MDk3ODA0ZDk2YzUzZmI0NTg1MmEzNjc=
<-  235 Authentication successful
-> MAIL FROM:<12345@host.info>
<-  250 sender <12345@host> OK
 -> RCPT TO:<host@me.com>
<-  250 recipient <host@me.com> OK
 -> DATA
<-  354 go ahead, make my day
 -> Date: Wed, 14 Jan 2015 17:01:28 +0000
 -> To: host@me.com
 -> From: 12345@host.info
 -> Subject: test Wed, 14 Jan 2015 17:01:28 +0000
 -> X-Mailer: swaks v20111230.0 jetmore.org/john/code/swaks/
 ->
 -> This is a test mailing
 ->
 -> .

Best Answer

After chatting with Nick, the problems was the Haraka only advertised authentication to requests coming form localhost. I changed my transport file/relayhost in main.cf to from referring my domain to localhost. Everything is working now.