这是我知道的最简单的发邮件架构,只发邮件!
具体原理:服务器利用邮箱的POP3/SMTP服务,登录A邮箱向B邮箱发送邮件。
- apt-get -y install msmtp #红帽系列自行yum
- chmod 600 ~/.msmtprc
- vim /etc/msmtprc ($HOME/.msmtprc) #没有这文件就创建文件
- account default
- host smtp.exmail.qq.com
- port 25
- from email@email.com
- tls off
- auth login
- user email@email.com
- password password
- logfile /tmp/msmtp.log
- vim /etc/Muttrc ($HOME/.msmtprc)
- set sendmail = "/usr/bin/msmtp"
- set from = support@aliyun
- set realname = "support"
- # 解决乱码
- set rfc2047_parameters=yes
- set charset="utf-8"
- # 设置换行
- set markers=no
- # 不保存发送的邮件
- unset record
测试
- echo "test" | mutt -s "这是一封警告信息,服务器中的某服务已经停止" QQ号@qq.com -a test.zip #B邮箱,除了这用了B,其他全是A,-a 加附件
- #test是内容,警告是标题
帮助信息
- mutt --help
- mutt: invalid option -- '-'
- Mutt 1.5.20 (2009-12-10)
- usage: mutt [<options>] [-z] [-f <file> | -yZ]
- mutt [<options>] [-x] [-Hi <file>] [-s <subj>] [-bc <addr>] [-a <file> [...] --] <addr> [...]
- mutt [<options>] [-x] [-s <subj>] [-bc <addr>] [-a <file> [...] --] <addr> [...] < message
- mutt [<options>] -p
- mutt [<options>] -A <alias> [...]
- mutt [<options>] -Q <query> [...]
- mutt [<options>] -D
- mutt -v[v]
- options:
- -A <alias> expand the given alias
- -a <file> attach a file to the message #邮件添加附件,可以添加多个,多个-a
- -b <address> specify a blind carbon-copy (BCC) address #指定密件副本的收信人地址
- -c <address> specify a carbon-copy (CC) address #指定副本的收信人地址,抄送
- -D print the value of all variables to stdout
- -e <command> specify a command to be executed after initialization
- -f <file> specify which mailbox to read #指定要载入的邮件文件
- -F <file> specify an alternate muttrc file #指定mutt程序的设置文件,而不读取预设的.muttrc文件
- -H <file> specify a draft file to read header and body from #将指定的邮件草稿送出
- -i <file> specify a file which Mutt should include in the body #将指定文件插入邮件内文中
- -m <type> specify a default mailbox type #指定预设的邮件信箱类型
- -n causes Mutt not to read the system Muttrc #不要去读取程序培植文件
- -p recall a postponed message #在mutt中编辑完邮件后,而不想将邮件立即送出,可将该邮件暂缓寄出
- -Q <variable> query a configuration variable
- -R open mailbox in read-only mode #以只读的方式开启邮件文件
- -s <subj> specify a subject (must be in quotes if it has spaces) #指定邮件的主题
- -v show version and compile-time definitions #显示mutt的版本信息以及当初编译此文件时所给予的参数
- -x simulate the mailx send mode #模拟mailx的编辑方式
- -y select a mailbox specified in your `mailboxes' list
- -z exit immediately if there are no messages in the mailbox #与-f参数一并使用时,若邮件文件中没有邮件即不启动mutt
- -Z open the first folder with new message, exit immediately if none
- -h
this help message #帮助文件 - -- separate filename(s) and recipients,
- when using -a, -- is mandatory