使用 ssmtp 发送电子邮件发件人值问题

使用 ssmtp 发送电子邮件发件人值问题

我正在尝试使用 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!'

相关内容