![使用 ssmtp 发送电子邮件发件人值问题](https://linux22.com/image/772128/%E4%BD%BF%E7%94%A8%20ssmtp%20%E5%8F%91%E9%80%81%E7%94%B5%E5%AD%90%E9%82%AE%E4%BB%B6%E5%8F%91%E4%BB%B6%E4%BA%BA%E5%80%BC%E9%97%AE%E9%A2%98.png)
我正在尝试使用 ssmtp 从我的 cron 脚本发送一封电子邮件,电子邮件工作正常,但“发件人”值始终显示,我不想使用它,因为我需要使用类似的东西,Ubuntu <[email protected]>
From="Cron Report <[email protected]>"
ssmtp配置文件
#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=postmaster
# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=####################
# Where will the mail seem to come from?
#rewriteDomain=
# The full hostname
hostname=example.com
AuthUser=####################
AuthPass==####################
FromLineOverride=NO
UseSTARTTLS=YES
#From="Cron Report <[email protected]>"
# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
#FromLineOverride=YES
重新命名
root:[email protected]
答案1
不确定如何更改配置中的设置,但下面的方法对我有用。
1). 取消注释ssmtp.conf:
FromLineOverride=YES
并在 crontab 本身中指定“发件人”地址(不是下面每 5 分钟发送一封电子邮件;):
MAILTO=<[email protected]>
MAILFROM=<[email protected]>
*/5 * * * * echo 'Test email from crontab. Skynet takes over the world!'