主要是舊版msmtp沒有處理好email header
現在的smtp伺服器會檢查mail header
寄件人跟帳號不一致不給寄
收件人不是合法mail address自然不能寄
#!/bin/bash # Workaround until mtmsp >= 1.8.8 in Ubuntu 20.10. root_alias=`grep "^root" /etc/aliases | cut -d: -f 2 | sed "s/\s*//g"` sed -e "s/From: root (Cron Daemon)/From:<your email address> /" | \ sed -e "s/To: root/To: $root_alias/g" | msmtp $BASH_ARGV
Refer:
1. Sending cron emails to Office365 via msmtp fails
https://www.reddit.com/r/debian/comments/p7xf10/sending_cron_emails_to_office365_via_msmtp_fails/
2.https://serverfault.com/questions/321221/setting-from-header-for-cron-email-using-msmtp