Estou tentando configurar o sendmail
para retransmitir email por meio do servidor smtp externo:
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
Arquivo Authinfo
AuthInfo:212.227.15.142 "U:[email protected]" "I:[email protected]" "P:*********" "M:LOGIN PLAIN"
Após cada alteração, faço isso:
m4 sendmail.mc > sendmail.cf
makemap hash authinfo < authinfo
make
Todos os comandos são executados sem problemas.
Mas quando eu envio um e-mail usando a função mail()
php em var/log/mail.log
, obtive:
(Eu tento enviar para ****@gmx.com
endereço de email)
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.
Eu acho que o sendmail não lê as credenciais smtp ou algo assim (ip 212.227.15.142
(smarthost) não está no log).
UPDATE
Quando eu tento:
sendmail -v -s "test" [email protected]
Eu obtenho isso, portanto, não vejo nenhum traço da minha autenticação smtp ou ip smarthost.
[email protected],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:<[email protected]> [email protected]
250 2.1.0 <[email protected]>... Sender ok
>>> RCPT To:<[email protected]>
>>> RCPT To:<[email protected]>
>>> DATA
250 2.1.5 <[email protected]>... Recipient ok
550 5.1.1 <[email protected]>... User unknown
354 Enter mail, end with "." on a line by itself
>>> .
050 <[email protected]>... 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:<[email protected]> SIZE=274
050 250 2.1.0 OK j25-v6si9299388wme.67 - gsmtp
050 >>> RCPT To:<[email protected]>
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 <[email protected]>... Sent (OK 1531149023 j25-v6si9299388wme.67 - gsmtp)
250 2.0.0 w69FANdO004647 Message accepted for delivery
[email protected]... 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:<[email protected]>
>>> DATA
250 2.1.5 <[email protected]>... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .
050 <[email protected]>... Connecting to local...
050 <[email protected]>... 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
Suponho que o log deve indicar "via relay" e não "via esmtp", algo está errado na minha configuração.
EDIT 2
Por qualquer motivo, eu tenho que modificar o sendmail.cf diretamente, porque a modificação do sendmail.mc e a próxima ação "make". Agora o smarthost está funcionando.