1

I am trying to config sendmail to relay mail through external smtp server:

sendmail.mc

include(`/etc/mail/m4/dialup.m4')dnl
include(`/etc/mail/m4/provider.m4')dnl
dnl # 
dnl # Default Mailer setup
define('SMART_HOST','212.227.15.142')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl
FEATURE(`authinfo')dnl 
MAILER_DEFINITIONS
MAILER(`local')dnl
MAILER(`smtp')dnl

Authinfo file

AuthInfo:212.227.15.142 "U:myuser@mydomain.es" "I:myuser@mydomain.es" "P:*********" "M:LOGIN PLAIN" 

After each change I do this:

m4 sendmail.mc > sendmail.cf
makemap hash authinfo < authinfo
make

All commands are executed without problems.

But when I send a mail using mail() php function in var/log/mail.log I got:

(I try to send to ****@gmx.com mail address)

Jul  6 09:05:06 ubuntu sendmail[63599]: w667561E063599: to=*****@gmx.com, ctladdr=********@mydomain.es (33/33), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30208, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (w66756Vp063600 Message accepted for delivery)
Jul  6 09:05:06 ubuntu sm-mta[63602]: w66756Vp063600: to=<*****@gmx.com>, delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=120544, relay=mx01.gmx.net. [212.227.17.4], dsn=4.0.0, stat=Deferred: Connection refused by mx01.gmx.net.

I think that sendmail does not read the smtp credentials or something (ip 212.227.15.142 (smarthost) is not on the log).

UPDATE

When I try:

sendmail -v -s "test" rj1000@gmail.com 

I obtain this, thus I don't see any trace of my smtp authentication or smarthost ip.

rj1000@gmail.com,test... Connecting to [127.0.0.1] via relay...
220 localhost.localdomain ESMTP Sendmail 8.15.2/8.15.2/Debian-3; Mon, 9 Jul 2018 17:10:23 +0200; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]
>>> EHLO localhost.localdomain
250-localhost.localdomain Hello localhost [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-EXPN
250-VERB
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH PLAIN
250-DELIVERBY
250 HELP
>>> VERB
250 2.0.0 Verbose mode
>>> MAIL From:<root@localhost.localdomain> AUTH=root@localhost.localdomain
250 2.1.0 <root@localhost.localdomain>... Sender ok
>>> RCPT To:<rj1000@gmail.com>
>>> RCPT To:<test@localhost.localdomain>
>>> DATA
250 2.1.5 <rj1000@gmail.com>... Recipient ok
550 5.1.1 <test@localhost.localdomain>... User unknown
354 Enter mail, end with "." on a line by itself
>>> .
050 <rj1000@gmail.com>... Connecting to gmail-smtp-in.l.google.com. via esmtp...
050 220 mx.google.com ESMTP j25-v6si9299388wme.67 - gsmtp
050 >>> EHLO localhost.localdomain
050 250-mx.google.com at your service, [212.145.243.67]
050 250-SIZE 157286400
050 250-8BITMIME
050 250-STARTTLS
050 250-ENHANCEDSTATUSCODES
050 250-PIPELINING
050 250-CHUNKING
050 250 SMTPUTF8
050 >>> STARTTLS
050 220 2.0.0 Ready to start TLS
050 >>> EHLO localhost.localdomain
050 250-mx.google.com at your service, [212.145.243.67]
050 250-SIZE 157286400
050 250-8BITMIME
050 250-ENHANCEDSTATUSCODES
050 250-PIPELINING
050 250-CHUNKING
050 250 SMTPUTF8
050 >>> MAIL From:<root@localhost.localdomain> SIZE=274
050 250 2.1.0 OK j25-v6si9299388wme.67 - gsmtp
050 >>> RCPT To:<rj1000@gmail.com>
050 >>> DATA
050 250 2.1.5 OK j25-v6si9299388wme.67 - gsmtp
050 354  Go ahead j25-v6si9299388wme.67 - gsmtp
050 >>> .
050 250 2.0.0 OK 1531149023 j25-v6si9299388wme.67 - gsmtp
050 <rj1000@gmail.com>... Sent (OK 1531149023 j25-v6si9299388wme.67 - gsmtp)
250 2.0.0 w69FANdO004647 Message accepted for delivery
rj1000@gmail.com... Sent (w69FANdO004647 Message accepted for delivery)
>>> RSET
250 2.0.0 Reset state
root... Using cached ESMTP connection to [127.0.0.1] via relay...
>>> MAIL From:<> SIZE=1024
250 2.1.0 <>... Sender ok
>>> RCPT To:<root@localhost.localdomain>
>>> DATA
250 2.1.5 <root@localhost.localdomain>... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .
050 <root@localhost.localdomain>... Connecting to local...
050 <root@localhost.localdomain>... Sent
250 2.0.0 w69FANdQ004647 Message accepted for delivery
root... Sent (w69FANdQ004647 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 localhost.localdomain closing connection

I suppose that the log must indicate "via relay" and not "via esmtp", something is wrong in my config.

EDIT 2

For any reason, I have to modify sendmail.cf directly, because sendmail.mc modification and the next "make" action. Now smarthost is working.

0

The log indicates relay=mx01.gmx.net.

Jul 6 09:05:06 ubuntu sm-mta[63602]: w66756Vp063600: to=<*****@gmx.com>, delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=120544, relay=mx01.gmx.net. [212.227.17.4], dsn=4.0.0, stat=Deferred: Connection refused by mx01.gmx.net.

It's trying to relay but the SMTP server running on mx01.gmx.net does not accept relaying

Connection refused by mx01.gmx.net.

Just configure mx01.gmx.net to allow relay from your MTA.

| improve this answer | |
  • No. mx01.gmx.net has not the ip that i indicated in smarthost (212.227.15.142). – dlopezgonzalez Jul 9 '18 at 13:13
0

The problem was that sendmail.cf was not update from make command. I recommend check the sendmail.cf content or directly modify it. With this command I finally to achieve to create a valid cf file from mc:

m4 sendmail.mc > sendmail.cf
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.