Configuring Sendmail on Ubuntu 14.04

xiaoxiao2021-02-27  284

原文: https://www.abeautifulsite.net/configuring-sendmail-on-ubuntu-1404

注意默认ubuntu只向自己(127.0.0.1)发送邮件。

vim /etc/mail/sendmail.mc

找到

DAEMON_OPTIONS(`Family=inet, Name=MTA-v4, Port=smtp, Addr=127.0.0.1')dnl

这一行,将127.0.0.1改成0.0.0.0,表明可以连接到任何服务器。 生成新的配置文件: cd /etc/mail mv sendmail.cf sendmail.cf-bak //做一个备份 m4 sendmail.mc > sendmail.cf // “>”的左右有空格。若提示错误说明你没有安装sendmail-cf 软件包 参考: http://funtime.blog.51cto.com/8807074/1678580

Install and configure Sendmail on Ubuntu

This should help you get Sendmail installed with basic configuration on Ubuntu.

If sendmail isn’t installed, install it:

sudo apt-get install sendmail

Configure /etc/hosts file:

sudo vi /etc/hosts

Make sure the line looks like this:

127.0.0.1 localhost yourhostname

Run Sendmail’s config and answer ‘Y’ to everything:

sudo sendmailconfig

Restart apache

sudo service apache2 restart

参考: https://gist.github.com/adamstac/7462202

测试了一下发送邮件,但是给我qq邮箱发送,发现失败了 在/var/log/mail.log里发现了失败信息Service unavailable。

May 4 15:12:48 ubuntu sendmail[26995]: v447Clle026995: from=cqq@localhost, size=99, class=0, nrcpts=1, msgid=<201705040712.v447Clle026995@localhost.localdomain>, relay=cqq@localhost May 4 15:12:48 ubuntu sm-mta[26996]: v447CmKh026996: from=<cqq@localhost.localdomain>, size=375, class=0, nrcpts=1, msgid=<201705040712.v447Clle026995@localhost.localdomain>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1] May 4 15:12:48 ubuntu sendmail[26995]: v447Clle026995: to=<56xxxxxxx@qq.com>, ctladdr=cqq@localhost (1000/1000), delay=00:00:01, xdelay=00:00:00, mailer=relay, pri=30099, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (v447CmKh026996 Message accepted for delivery) May 4 15:12:49 ubuntu sm-mta[26998]: STARTTLS=client, relay=mx3.qq.com., version=TLSv1.2, verify=FAIL, cipher=AES128-SHA256, bits=128/128 May 4 15:12:50 ubuntu sm-mta[26998]: v447CmKh026996: to=<56xxxxxxx@qq.com>, ctladdr=<cqq@localhost.localdomain> (1000/1000), delay=00:00:02, xdelay=00:00:02, mailer=esmtp, pri=120375, relay=mx3.qq.com. [183.232.94.123], dsn=5.0.0, stat=Service unavailable May 4 15:12:50 ubuntu sm-mta[26998]: v447CmKh026996: v447CoKh026998: DSN: Service unavailable May 4 15:12:50 ubuntu sm-mta[26998]: v447CoKh026998: to=<cqq@localhost.localdomain>, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30000, dsn=2.0.0, stat=Sent This is a MIME-encapsulated message --v447CoKh026998.1493881970/localhost.localdomain The original message was received at Thu, 4 May 2017 15:12:48 +0800 from localhost [127.0.0.1] ----- The following addresses had permanent fatal errors ----- <56xxxxxxx@qq.com> (reason: 550 Mail content denied. http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=20022&&no=1000726) ----- Transcript of session follows ----- ... while talking to mx3.qq.com.: >>> DATA <<< 550 Mail content denied. http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=20022&&no=1000726 554 5.0.0 Service unavailable --v447CoKh026998.1493881970/localhost.localdomain Content-Type: message/delivery-status Reporting-MTA: dns; localhost.localdomain Received-From-MTA: DNS; localhost Arrival-Date: Thu, 4 May 2017 15:12:48 +0800 Final-Recipient: RFC822; 56xxxxxxx@qq.com Action: failed Status: 5.2.0 Remote-MTA: DNS; mx3.qq.com Diagnostic-Code: SMTP; 550 Mail content denied. http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=20022&&no=1000726 Last-Attempt-Date: Thu, 4 May 2017 15:12:50 +0800

访问它给出了链接 http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=20022&&no=1000726 得到 但是给我的protonmail发的邮件却接收成功了。 先是

cqq@ubuntu:/etc/mail$ echo "Test sendmail" |mail -s "Test subject" xxxxxxx@protonmail.com You have new mail in /var/mail/cqq

于是我去/var/log/mail.log里没发现与protonmail有关的错误。 反而找到了

May 4 15:12:58 ubuntu sendmail[27002]: v447Cqdm027002: from=cqq@localhost, size=107, class=0, nrcpts=1, msgid=<201705040712.v447Cqdm027002@localhost.localdomain>, relay=cqq@localhost May 4 15:12:58 ubuntu sm-mta[27003]: v447CwlX027003: from=<cqq@localhost.localdomain>, size=383, class=0, nrcpts=1, msgid=<201705040712.v447Cqdm027002@localhost.localdomain>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1] May 4 15:12:58 ubuntu sendmail[27002]: v447Cqdm027002: to=<xxxxxxx@protonmail.com>, ctladdr=cqq@localhost (1000/1000), delay=00:00:06, xdelay=00:00:00, mailer=relay, pri=30107, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (v447CwlX027003 Message accepted for delivery) May 4 15:13:01 ubuntu sm-mta[27005]: STARTTLS=client, relay=mail.protonmail.ch., version=TLSv1.2, verify=FAIL, cipher=ECDHE-RSA-AES256-GCM-SHA384, bits=256/256 May 4 15:13:03 ubuntu sm-mta[27005]: v447CwlX027003: to=<xxxxxx@protonmail.com>, ctladdr=<cqq@localhost.localdomain> (1000/1000), delay=00:00:05, xdelay=00:00:05, mailer=esmtp, pri=120383, relay=mail.protonmail.ch. [185.70.40.25], dsn=2.0.0, stat=Sent (Ok: queued as E0D214AF)

但是是在Spam这一栏。开始在Inbox里没找到,后来才发现。

附:How To Install the Send-Only Mail Server “Exim” on Ubuntu 12.04

转载请注明原文地址: https://www.6miu.com/read-3499.html

最新回复(0)