Fedora 20: mutt/msmtp: 使用Gmail发送邮件

在mutt里使用fetchmail接受gmail很容易, ~/.fetchmailrc一句命令就能搞定. 今天记录一下, 使用msmtp发送Gmail, 重点在于必须使用tls, 需要的认证文件需要从ca-certificates包里获得, 路径为: /etc/pki/tls/certs/ca-bundle.crt, 这和ubuntu里不一样.

# cat ~/.msmtprc
account default
host smtp.company.com
port 25
from akong@company.com
logfile ~/Mail/.msmtp.log

account gmail
protocol smtp
tls on
tls_starttls on
tls_trust_file /etc/pki/tls/certs/ca-bundle.crt
host smtp.gmail.com
port 587
auth login
from kongjianjun@gmail.com
user kongjianjun@gmail.com
password xxxxxx
logfile ~/Mail/.msmtp.gmail.log


$ echo -e "Subject: Test MailrnrnThis is a test mail" |msmtp --debug --from=kongjianjun@gmail.com -t kongjianjun@gmail.com

在~/.muttrc里添加两个宏用来选择发送账号, 这个设置完新建邮件使用最新设置的地址.在编辑邮件过程中使用 <esc>f 来编辑发送地址.

macro generic "<esc>1" ":set from=akong@company.com"
macro generic "<esc>2" ":set from=kongjianjun@gmail.com"

macro generic "<esc>1" ":set from=akong@company.com ; my_hdr BCC:Amos Kong <akong@company.com>"
macro generic "<esc>2" ":set from=kongjianjun@gmail.com ; unmy_hdr BCC"

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.