获取sendmail正确发送来自AWS EC2服务器的电子邮件时出错(服务器地址域不存在)

我无法使用sendmail从我的AWS EC2机器发送电子邮件。

我正在使用以下命令发送电子邮件:

sendmail -vt < mail.txt 

mail.txt文件具有以下内容(为了安全性而编辑):

 To: [email protected] Subject: Put a subject here From: [email protected] Message body 

当我运行sendmail它看起来像事情正在工作:

 >>> MAIL From:<[email protected]> SIZE=128 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 s0FLLsxw009758 Message accepted for delivery [email protected]... Sent (s0FLLsxw009758 Message accepted for delivery) 

但是,我从来没有收到我的雅虎帐户的电子邮件。 接下来我检查了/ var / log / messages,它说我在“/ var / spool / mail / ec2-user”中有新邮件。 这是我在该文件中看到的:

  ----- The following addresses had permanent fatal errors ----- <[email protected]> (reason: 553 #5.1.8 Domain of sender address <[email protected]> does not exist) ----- Transcript of session follows ----- ... while talking to smtp02.yahoo.com.: >>> MAIL From:<[email protected]> SIZE=669 <<< 553 #5.1.8 Domain of sender address <[email protected]> does not exist 501 5.6.0 Data format error 

有人可以告诉我什么configuration是需要使这项工作? 上面的XXX是我的ip-XXX-YYY-ZZZ-AAA地址,它对应于我的EC2机器。

我做了一些寻找解决scheme,但没有发现为我工作到目前为止。

  ----- Transcript of session follows ----- ... while talking to smtp02.yahoo.com.: >>> MAIL From:<[email protected]> SIZE=669 <<< 553 #5.1.8 Domain of sender address <[email protected]> does not exist 

使用sendmail -f命令行选项显式设置信封发件人地址

要么

使您的sendmail使用“此主机电子邮件名称”($ j)与公共MX或DNSlogging。
https://askubuntu.com/questions/9540/how-do-i-change-the-computer-name

要么

让您的sendmail masquearde作为另一个主机用于电子邮件的目的
https://www.sendmail.com/sm/open_source/docs/m4/masquerading.html

大量的EC2地址空间被几个电子邮件提供商列入黑名单。 如果您需要从实例发送电子邮件,则需要通过非EC2主机进行中继,否则使用AWS的SES服务发送电子邮件。

就个人而言,我使用SES,因为它很容易与您的MTA整合,价格非常低(或免费),但最大的电子邮件数量。