linux使用msmtp+mutt通过Google smtp 发送邮件

安装msmtp

#wget httpncu.dl.sourceforge.netprojectmsmtpmsmtp1.4.18msmtp-1.4.18.tar.bz2
#tar xjvf msmtp-1.4.18.tar.bz2
#cd msmtp-1.4.18
#.configure --prefix=usrlocalmsmtp
#make
#make install
#mkdir -p usr/local/msmtp/certs
#vi /usr/local/msmtp/certs/Thawte_Premium_Server_CA.pem

-----BEGIN CERTIFICATE-----
MIIDIDCCAomgAwIBAgIENd70zzANBgkqhkiG9w0BAQUFADBOMQswCQYDVQQG
EwJVUzEQMA4GA1UEChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1
cmUgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MB4XDTk4MDgyMjE2NDE1MVoXDTE4
MDgyMjE2NDE1MVowTjELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0VxdWlmYXgx
LTArBgNVBAsTJEVxdWlmYXggU2VjdXJlIENlcnRpZmljYXRlIEF1dGhvcml0
eTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwV2xWGcIYu6gmi0fCG2R
FGiYCh7+2gRvE4RiIcPRfM6fBeC4AfBONOziipUEZKzxa1NfBbPLZ4C/QgKO
/t0BCezhABRP/PvwDN1Dulsr4R+AcJkVV5MW8Q+XarfCaCMczE1ZMKxRHjuv
K9buY0V7xdlfUNLjUA86iOe/FP3gx7kCAwEAAaOCAQkwggEFMHAGA1UdHwRp
MGcwZaBjoGGkXzBdMQswCQYDVQQGEwJVUzEQMA4GA1UEChMHRXF1aWZheDEt
MCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2VydGlmaWNhdGUgQXV0aG9yaXR5
MQ0wCwYDVQQDEwRDUkwxMBoGA1UdEAQTMBGBDzIwMTgwODIyMTY0MTUxWjAL
BgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAUSOZo+SvSspXXR9gjIBBPM5iQn9Qw
HQYDVR0OBBYEFEjmaPkr0rKV10fYIyAQTzOYkJ/UMAwGA1UdEwQFMAMBAf8w
GgYJKoZIhvZ9B0EABA0wCxsFVjMuMGMDAgbAMA0GCSqGSIb3DQEBBQUAA4GB
AFjOKer89961zgK5F7WF0bnj4JXMJTENAKaSbn+2kmOeUJXRmm/kEd5jhW6Y
7qj/WsjTVbJmcVfewCHrPSqnI0kBBIZCe/zuf6IWUrVnZ9NA2zsmWLIodz2u
FHdh1voqZiegDfqnc1zqcPGUIWVEX/r87yloqaKHee9570+sB3c4
-----END CERTIFICATE-----

#touch /usr/local/msmtp/msmtp.log
#vi ~.msmtprc

account default
host smtp.gmail.com
port 587
from [email protected] 
tls on
tls_starttls on
tls_trust_file /usr/local/msmtp/certs/Thawte_Premium_Server_CA.pem
auth on
user lixingping1985
password *******
logfile /usr/local/msmtp/msmtp.log


#vi /usr/local/msmtp/etc/msmtprc 为全局配置文件

account default
host smtp.gmail.com
port 587
from [email protected] 
tls on
tls_starttls on
tls_trust_file /usr/local/msmtp/certs/Thawte_Premium_Server_CA.pem
auth on
user lixingping1985
password ******
logfile /usr/local/msmtp/msmtp.log

测试
#/usr/local/msmtp/bin/msmtp [email protected] 
随意写一些内容
但是当你登陆邮件查看进可能还是收不到,这个没关系
CTRL+C

安装mutt
#wget ftpftp.mutt.orgmuttdevelmutt-1.5.20.tar.gz
#tar zxvf mutt-1.5.20.tar.gz
#cd mutt-1.5.20
#.configure --prefix=usrlocalmutt

如果报configure: error: no curses library found

redhat那就安装ncurses-5.5-24.20060715.i386.rpm  ncurses-devel-5.5-24.20060715.i386.rpm这两个安装包就可以

如果你的系统是Ubuntu或Debian:

apt-cache search ncurses

apt-get install libncurses5-dev


#make && make install
#vi ~.muttrc

set sendmail=usrlocalmsmtpbinmsmtp
set realname= "[email protected] "
set" use_from=yes
set editor=vi

#vi /usr/local/mutt/etc/Muttrc 为全局配置文件最底下加入
set sendmail=usrlocalmsmtpbinmsmtp
set realname= "[email protected] "
set" use_from=yes
set editor=vi


测试mutt+msmtp
echo "邮件内容" | /usr/local/mutt/bin/mutt -s "邮件主题" [email protected]  
-c [email protected]
命令解释:
发送内容为 邮件内容 标题为 邮件主题 的邮件到[email protected]  同时抄送
[email protected]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/16111659/viewspace-679577/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/16111659/viewspace-679577/

你可能感兴趣的:(操作系统)