我试图将sendmail配置为通过外部smtp服务器中继邮件:
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')dnlAuthinfo文件
AuthInfo:212.227.15.142 "U:myuser@mydomain.es" "I:myuser@mydomain.es" "P:*********" "M:LOGIN PLAIN" 每次更改后,我都会这样做:
m4 sendmail.mc > sendmail.cf
makemap hash authinfo < authinfo
make所有命令都没有问题地执行。
但是,当我使用mail() php函数在var/log/mail.log中发送邮件时,我得到:
(我试图发送到****@gmx.com邮件地址)
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.我认为sendmail不读取smtp凭据或其他内容(ip 212.227.15.142 (智能版)不在日志中)。
更新
当我尝试:
sendmail -v -s "test" rj1000@gmail.com 因此,我没有看到smtp身份验证或智能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: AUTH=root@localhost.localdomain
250 2.1.0 ... Sender ok
>>> RCPT To:
>>> RCPT To:
>>> DATA
250 2.1.5 ... Recipient ok
550 5.1.1 ... User unknown
354 Enter mail, end with "." on a line by itself
>>> .
050 ... 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: SIZE=274
050 250 2.1.0 OK j25-v6si9299388wme.67 - gsmtp
050 >>> RCPT To:
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 ... 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:
>>> DATA
250 2.1.5 ... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .
050 ... Connecting to local...
050 ... 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我假设日志必须表明“通过中继”而不是“通过esmtp",在我的配置中有问题。
<#>EDIT 2
由于任何原因,我必须直接修改sendmail.cf,因为sendmail.mc修改和下一个"make“操作。现在智者开始工作了。
发布于 2018-07-20 10:40:56
问题是,sendmail.cf没有从make命令中更新。我建议检查sendmail.cf内容或直接修改它。使用这个命令,我最终要实现从mc创建一个有效的cf文件:
m4 sendmail.mc > sendmail.cf发布于 2018-07-09 12:07:28
日志指示中继=mx01.gmx.net。
7月6日09:05:06 ubuntu : w66756Vp063600: to=\*\*\*\*\*@gmx.com,delay=00:00:00,xdelay=00:00:00,mailer=esmtp,pri=120544,中继= mx01.gmx.net。,dsn=4.0.0,stat=Deferred: mx01.gmx.net拒绝连接。
它试图中继,但是运行在mx01.gmx.net上的SMTP服务器不接受中继
Connection refused by mx01.gmx.net.只需将mx01.gmx.net配置为允许从MTA中继。
https://serverfault.com/questions/919727
复制相似问题