sendmail 在电子邮件中给出空的收件人

sendmail 在电子邮件中给出空的收件人

我正在使用一个脚本,该脚本进行备份并使用 sendmail 发送状态电子邮件,但其发送的电子邮件带有空白标签,这里是它的图像

以下是脚本的一部分

    #Email Settings
    Message_Success="Backup generated successfully"
    Message_Failure="Problem occured while generating Backup"

    Subject="Backup Status Mail"
    Sender_Name=Backup
    Recipients="[email protected]"

echo "Subject:$Subject\n\n$Message_Failure" | sendmail -F $Sender_Name $Recipients

echo "Subject:$Subject\n\n$Message_Success" | sendmail -F $Sender_Name $Recipients

能解决这个问题吗,这样我就能看到谁收到了电子邮件。谢谢。

答案1

我会把收件人放在消息中并使用 sendmail 的-t标志:

#Email Settings
Message_Success="Database Backup generated successfully"
Message_Failure="Problem occured while generating Database Backup please verify"
Subject="Database Backup Status Mail"
Sender_Name=DatabaseBackup
Recipients="[email protected],[email protected]"

sendmail -F $Sender_Name -it <<END_MESSAGE
To: $Recipients
Subject: $Subject

$Message_Success
END_MESSAGE

相关内容