gpt4 book ai didi

email - 从命令行使用 sendmail

转载 作者:行者123 更新时间:2023-12-04 11:08:33 34 4
gpt4 key购买 nike

关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。












想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。

4年前关闭。




Improve this question




我正在尝试编写一个 bash 脚本,由 cron 任务运行,它会在某些情况下向我发送电子邮件。

为了尝试让 sendmail 使用我的 Sendgrid SMTP 设置,我编辑了 /etc/postfix/main.cf 包含以下内容的文件:

smtp_sasl_password_maps = static:<username>:<password>
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = may
smtp_tls_security_level=encrypt
header_size_limit = 4096000
relayhost = [smtp.sendgrid.net]:587

我使用 重新启动了 postfix须藤/etc/init.d/postfix 重启

并尝试使用以下命令从命令行发送电子邮件:

sendmail my@email.com

这导致以下输出:

You have new mail in /var/mail/ubuntu



为什么 sendgrid 不使用我在 main.cf 中指定的 Sendgrid SMTP 详细信息与我的电子邮件一起发送?

请注意,此问题仅与 sendmail 相关,我不想安装其他 SMTP 客户端和应用程序,它需要按原样工作。

最佳答案

我的 Postfix 配置是错误的。我需要使用以下内容:

smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = static:<username>:<password>
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = may
header_size_limit = 4096000
relayhost = [smtp.sendgrid.net]:587

通过 bash 脚本发送电子邮件的方式如下:
sendmail email@address.com <<EOF
subject:This is a test
from:from@address.com
Body message here...
EOF

关于email - 从命令行使用 sendmail,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16457387/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com