【发布时间】:2017-05-21 17:16:16
【问题描述】:
我使用Integrating Amazon SES with Sendmail 配置了 SES 以允许它从经过验证的电子邮件地址发送电子邮件。我能够使用经过验证的电子邮件地址从命令行成功发送电子邮件:
sudo /usr/sbin/sendmail -f from@example.com to@example.com < file_to_send.txt
接下来我设置了一个 bash 脚本来收集一些每日报告信息。
#!/bin/bash
# copy the cw file
cp /var/log/cwr.log /cwr_analysis/cwr.log
# append the cw info to the subject file
cat /cwr_analysis/subject.txt /cwr_analysis/cwr.log > /cwr_analysis/daily.txt
# send the mail
/usr/sbin/sendmail -f from@example.com to@example.com < /cwr_analysis/daily.txt
如果我从命令行手动运行 bash 脚本,则会按原样收集报告并通过电子邮件发送。我更改了文件的权限以允许它由 root 执行(类似于 AWS 实例上的其他 CRON 作业):
-rwxr-xr-x 1 root root 375 Jan 6 17:37 cwr_email.sh
问题
我设置了一个 CRON 作业并将其设置为每 5 分钟运行一次以进行测试(脚本设计为在生产开始后每天运行一次):
*/5 * * * * /home/ec2-user/cwr_email.sh
bash 脚本复制并正确附加daily.txt 文件,但不发送电子邮件。电子邮件假脱机中没有退回邮件或任何其他错误。
我今天大部分时间都在寻找答案,但许多搜索最终都陷入了死胡同,几乎没有关于使用 CRON 通过 AWS SES 发送电子邮件的信息。
我该如何解决这个问题?
【问题讨论】:
-
cron作业是否添加为
root用户? -
是的@helloV,cron是给root用户的。
-
你试过了吗? serverfault.com/a/615344
标签: bash amazon-web-services cron amazon-ses