macOS下用命令行发邮件

时间:2024-03-04 20:33:01
brew install msmtp

vi ~/.mailrc
set sendmail=/usr/local/bin/msmtp
wq!

vi ~/.msmtprc

# Use an external SMTP server with insecure authentication.
# (manually choose an insecure authentication method.)
# Note that the password contains blanks.

defaults

####################################################################
# A sample configuration using sina.cn
####################################################################

account default
host smtp.sina.cn
port 25
from vincenthandsome@sina.cn
auth login
tls off
user vincenthandsome@sina.cn
password 2wsxzaq1
:wq!

chmod 600 ~/.msmtprc
echo "this\'s an apple." |mail 888888@qq.com
上述方法参考自https://my.oschina.net/uhziel/blog/186683