mail -s "test mail" [email protected] < messagebody.txt
Dec 16 06:45:23 Ambidextrous postfix/pickup[16021]: D493648123F: uid=1000 from=<praveen@Ambidextrous>
Dec 16 06:45:23 Ambidextrous postfix/cleanup[18325]: D493648123F: message-id=<20191216011523.D493648123F@Ambidextrous>
Dec 16 06:45:23 Ambidextrous postfix/qmgr[16022]: D493648123F: from=<praveen@Ambidextrous>, size=467, nrcpt=1 (queue active)
Dec 16 06:45:24 Ambidextrous postfix/smtp[18327]: connect to smtp.gmail.com[2404:6800:4003:c03::6d]:587: Network is unreachable
Dec 16 06:45:25 Ambidextrous postfix/smtp[18327]: D493648123F: to=<[email protected]>, relay=smtp.gmail.com[74.125.24.108]:587, delay=1.6, delays=0.1/0.03/1.3/0.2, dsn=5.7.0, status=bounced (host smtp.gmail.com[74.125.24.108] said: 530-5.7.0 Authentication Required. Learn more at 530 5.7.0 https://support.google.com/mail/?p=WantAuthError f81sm20379329pfa.118 - gsmtp (in reply to MAIL FROM command))
Dec 16 06:45:25 Ambidextrous postfix/cleanup[18325]: A19DA481245: message-id=<20191216011525.A19DA481245@Ambidextrous>
Dec 16 06:45:25 Ambidextrous postfix/bounce[18328]: D493648123F: sender non-delivery notification: A19DA481245
Dec 16 06:45:25 Ambidextrous postfix/qmgr[16022]: A19DA481245: from=<>, size=2688, nrcpt=1 (queue active)
Dec 16 06:45:25 Ambidextrous postfix/qmgr[16022]: D493648123F: removed
Dec 16 06:45:25 Ambidextrous postfix/local[18329]: A19DA481245: to=<praveen@Ambidextrous>, relay=local, delay=0.08, delays=0.05/0.01/0/0.02, dsn=2.0.0, status=sent (delivered to mailbox)
Dec 16 06:45:25 Ambidextrous postfix/qmgr[16022]: A19DA481245: removed
答案1
只需指定有效的发件人电子邮件地址,否则 GMail 将不会接受发送。
请在此处查看一些示例:https://www.binarytides.com/linux-mailx-command/
echo "This is the message body" | mail -s "Subject: Test Mail" -aFrom:aN\<[email protected]\> [email protected]
仅供参考,如果你想从脚本或命令行发送电子邮件并实现所有高级功能,一个好的解决方法是使用php邮件发送器库:附件、html 和文本格式,密钥管理信息系统,防晒指数...
你也可以检查你的 PostFix 配置,
/etc/postfix/sasl_passwd
它必须包含你的 GMail 帐户信息,如下所示:必须引用上一个文件, 然后使用它来编译 sasl passwd 文件[smtp.gmail.com]:587 [email protected]:password
/etc/postfix/main.cf
smtp_sasl_password_maps
postmap