linux下利用mutt来发mail

    1.Install
sudo apt-get install mutt msmtp
    2.Config    
sudo vim /etc/Muttrc

    增加如下内容

set sendmail="/usr/bin/msmtp"
set use_from=yes
set envelope_from=yes
set realname="yourname"
set from=your_mail_id@host

    然后msmtp的配置文件为~/.msmtprc,有时候不会自动创建,可以找个模板自己改

dpkg -L mstmp
mv /usr/share/doc/msmtp/examples/msmtprc-user.example ~/.msmtprc
sudo vim ~/.msmtprc

    内容大致如下  

# Example for a user configuration file

# Set default values for all following accounts.
defaults
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile ~/.msmtp.log

# A outlook service

# The SMTP server of the outlook.
account outlook 
host smtp-mail.outlook.com
port 587
from [email protected]
auth on
user [email protected]
password you_password

# Set a default account
account default : outlook

    记得修改文件权限

sudo chmod 755 ~/.msmtprc
    3.Usage
mutt

    或者

ehco "content" | mutt send_to_mail@host -s "subject" -a file

    可直接发送邮件

你可能感兴趣的:(linux下利用mutt来发mail)