jos*_*erk 7 email cron sendmail
我正在尝试编写一个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
Run Code Online (Sandbox Code Playgroud)
我使用sudo /etc/init.d/postfix restart重新启动了postfix
并尝试使用以下命令从命令行发送电子邮件:
sendmail my@email.com </tmp/email.txt
这导致以下输出:
您在/ var/mail/ubuntu中有新邮件
为什么sendgrid不使用我在main.cf中指定的Sendgrid SMTP详细信息发送我的电子邮件?
请注意,这个问题仅与sendmail有关,我不想安装其他SMTP客户端和应用程序,它需要按原样工作.
jos*_*erk 10
我的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
Run Code Online (Sandbox Code Playgroud)
通过bash脚本发送电子邮件如下:
sendmail email@address.com <<EOF
subject:This is a test
from:from@address.com
Body message here...
EOF
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
24005 次 |
| 最近记录: |