在我的 Redhat Prod 服务器上,我安装了 Sendmail,我将用它来将数据库备份完成邮件发送到我的电子邮件 ID。
当我从我的服务器 A 172.16.233.2 向我的电子邮件 ID 发送电子邮件时[电子邮件受保护]。使用
发送邮件-v[电子邮件受保护]< /opt/dailydbscriptoutput.txt
[email protected]... Connecting to [127.0.0.1] via relay...
220 db.erp.com ESMTP Sendmail 8.13.8/8.13.8; Thu, 7 Aug 2014 13:37:17 +0300
>>> EHLO pmmcdb.erp.com
250-db.erp.com Hello localhost.localdomain [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-DELIVERBY
250 HELP
>>> MAIL From:<[email protected]> SIZE=59
250 2.1.0 <[email protected]>... 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
>>> .
250 2.0.0 s77AbH2H025298 Message accepted for delivery
[email protected]... Sent (s77AbH2H025298 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 db.erp.com closing connection
我收到上述消息。但是当我检查日志 /var/log/maillog.我看到这个
Aug 7 12:18:41db sendmail[11808]: s779If28011808: from=emerg, size=59, class=0, nrcpts=1, msgid=<[email protected]>, relay=emerg@localhost
Aug 7 12:18:41 db sendmail[11809]: s779Ifss011809: from=<[email protected]>, size=342, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Aug 7 12:18:41 db sendmail[11808]: s779If28011808: [email protected], ctladdr=emerg (503/503), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30059, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (s779Ifss011809 Message accepted for delivery)
Aug 7 12:18:42 db sendmail[11811]: s779Ifss011809: to=<[email protected]>, ctladdr=<[email protected]> (503/503), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=120342, relay=mail1 [10.171.1.10], **dsn=5.6.0, stat=Data format error**
之前我遇到过与 DNS 相关的服务器问题。
名称服务器超时
所以我点击了这个链接设置 Sendmail 无需 DNS为了解决问题,在另一台测试服务器上它开始工作,然后我在此生产服务器上应用了相同的过程,但我无法发送消息
测试后
sendmail -Am -v [email protected] < /tmp/email.txt
[email protected]... Connecting to mail1 via relay...
220 mail1.etradeportal.net ESMTP Sendmail 8.13.1/8.13.1; Thu, 7 Aug 2014 15:18:51 +0300
>>> EHLO db.erp.com
250-mail1.etradeportal.net Hello [172.16.233.2], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5
250-DELIVERBY
250 HELP
>>> MAIL From:<[email protected]> SIZE=108
553 5.1.8 <[email protected]>... Domain of sender address [email protected] does not exist
/root/dead.letter... Saved message in /root/dead.letter
Closing connection to mail1
>>> QUIT
221 2.0.0 mail1.etradeportal.net closing connection
答案1
尝试下面的脚本:
#!/bin/sh
FILE=/opt/dailydbscriptoutput.txt
[email protected]
(cat - $FILE <<END) | /usr/sbin/sendmail -i $TO
TO: $TO
END
Sendmail 期望标头和正文以“原始”格式用空行分隔。
为了获得更好的调试信息,以 root 身份执行上述脚本,并将-Am -v
命令行选项传递给 sendmail。
定影Domain of sender address [email protected] does not exist
在接收主机上将db.erp.com
条目添加到/etc/hosts
文件 [db.erp.com 使用私有/“非公共”/“仅内联网”IP 地址]