参考链接
mac-os-x-下用命令行发送邮件
-
通过homebrew安装msmtp
$ brew install msmtp
-
编辑或者创建文件~/.mailrc 并写入以下内容
set sendmail=/usr/local/bin/msmtp
-
创建或者编辑 ~/.msmtprc 并写入以下内容
# Example for a user configuration file
# Set default values for all following accounts.
defaults
tls on
logfile ~/.msmtp.log
# A qqmail service
account example@qq.com
host smtp.qq.com
port 587
protocol smtp
auth on
from example@qq.com
user example@qq.com
tls on
tls_starttls on
# Your mac should have certificates in /etc/certificates/
# Pick one, if it doesn't work, try another one.
# If you have no certicicates there then Google it.
tls_trust_file /private/etc/ssl/cert.pem
# Set a default account
# You need to set a default account for Mail
account default : [example@qq.com](mailto:example@qq.com)
-
设置 ~/.msmtprc 文件权限为管理员可管理
$ chmod 600 ~/.msmtprc
-
在钥匙串访问中新建一个密码项 ( 钥匙串访问 ==> 文件 ==> 新建密码项 )
钥匙串项的名称: smtp://smtp.gmail.com
账户名称: example@gmail.com
密码: secret -
在终端 使用如下命令测试钥匙串密码是否配置成功 (点击永远允许钥匙串访问)
$ echo "Hello world" | Mail -s "msmtp test at
date" [someother@mail.com](mailto:someother@mail.com)
网友评论