邮件:无法解析地址

邮件:无法解析地址

这是我用来打包备份文件、写入标准输出,然后通过电子邮件通知将所有内容上传到 Amazon S3 的命令。

tar -czvf - --exclude-caches /var/www | s3cmd --reduced-redundancy --multipart-chunk-size-mb=30 put - s3://MY-BUCKET/`date +\%G-\%m-\%d`.tar.gz | mail -s "Weekly Backup"

除了命令之外,一切都正常mail。我认为我有一些语法错误。我得到:

mail: Cannot parse address `File '-' stored as 's3://MY-BUCKET/2014-08-31.tar.gz' (0 bytes in 2190.3 seconds' (while expanding `File '-' stored as 's3://MY-BUCKET/2014-08-31.tar.gz' (0 bytes in 2190.3 seconds'): Malformed email address
mail: Cannot parse address `-1.00 B/s) [1 of 1]' (while expanding `-1.00 B/s) [1 of 1]'): Malformed email address
root:~# tar -czvf - --exclude-caches /var/www | s3cmd --reduced-redundancy --multipart-chunk-size-mb=30 put - s3://MY-BUCKET/`date +\%G-\%m-\%d`.tar.gz
 | mail -s "Weekly Backup"

答案1

要通过(并使用 stdin 作为正文)发送邮件mail,请使用以下语法:

echo "test body" | mail -s 'test subject' [email protected]

欲了解更多信息,请参阅手册页man mail

相关内容