使用Integrating Amazon SES with Sendmail我配置了SES以允許它從驗證的電子郵件地址發送電子郵件。來自CRON的AWS SES sendmail失敗
sudo /usr/sbin/sendmail -f [email protected] [email protected] < 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 [email protected] [email protected] < /cwr_analysis/daily.txt
如果我在命令行手動運行bash腳本的報告收集和發送電子郵件,因爲它應該是。我更改文件的權限,使其能夠以root執行(類似於其他cron作業的AWS實例):
-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
是@helloV,cron用於root用戶。 –
你有試過嗎? http://serverfault.com/a/615344 –