从Bash发送电子邮件失败,没有错误消息

时间:2015-10-25 23:46:56

标签: macos bash email

我正在尝试从终端发送电子邮件(bash)。我做了:

echo "text" | mail -vs "subject"  "myself@address.com"

详细标志返回

Mail Delivery Status Report will be mailed to <Me>

但我的收件箱中既未收到Mail Delivery Status Report也未收到电子邮件。 Mail Delivery Status Report似乎保存在文件/var/mail/Me中。这是我收到的最后一份报告:

--EAB82C90F6D.1445818910/Remis-MacBook-Pro.local
Content-Description: Delivery report
Content-Type: message/delivery-status

Reporting-MTA: dns; Remis-MacBook-Pro.local
X-Postfix-Queue-ID: EAB82C90F6D
X-Postfix-Sender: rfc822; remi@Remis-MacBook-Pro.local
Arrival-Date: Sun, 25 Oct 2015 17:21:49 -0700 (PDT)

Final-Recipient: rfc822; myself@address.com
Action: delayed
Status: 4.4.1
Diagnostic-Code: X-Postfix; delivery temporarily suspended: connect to
    alt2.gmail-smtp-in.l.google.com[173.194.219.26]:25: Connection refused

--EAB82C90F6D.1445818910/Remis-MacBook-Pro.local
Content-Description: Message Headers
Content-Type: text/rfc822-headers

Return-Path: <remi@Remis-MacBook-Pro.local>
Received: by Remis-MacBook-Pro.local (Postfix, from userid 501)
        id EAB82C90F6D; Sun, 25 Oct 2015 17:21:49 -0700 (PDT)
To: myself@address.com
Message-Id: <20151026002149.EAB82C90F6D@Remis-MacBook-Pro.local>
Date: Sun, 25 Oct 2015 17:21:49 -0700 (PDT)
From: remi@Remis-MacBook-Pro.local (Remi)

--EAB82C90F6D.1445818910/Remis-MacBook-Pro.local--

出了什么问题?

我使用的是Mac OSX El Capitano版本10.11

1 个答案:

答案 0 :(得分:0)

我添加了these instructionsthese instructions

relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_use_tls = yes
smtp_sasl_mechanism_filter = plain

/etc/postfix/main.cf

我还创建了/etc/postfix/sasl_passwd并写了

[smtp.gmail.com]:587 username@gmail.com:password

在里面。然后我跑了

sudo chmod 600 /etc/postfix/sasl_passwd
sudo postmap /etc/postfix/sasl_passwd
sudo launchctl stop org.postfix.master
sudo launchctl start org.postfix.master

并更改了我的Google帐户设置以允许“安全性较低的应用”(请参阅​​说明here)。它有效!