1、安装sendmail: 1) centos下能够安装命令:yum -y install sendmail 2) 安装完后启动sendmail命令:service sendmail start 2、安装mail 安装命令:yum install -y mailx
一、经过文件内容发送linux
发送命令:mail -s 'mail test' abc@qq.com < mailtest.txt ("mail test"为邮件主题,abc@qq.com为收件人邮箱,mailtest.txt保存邮件内容) 或者:echo "邮件内容" |mail -s "主题" abc@qq.com
二、经过管道符直接发送centos
发送命令:echo "this is my test mail" | mail -s 'mail test' abc@qq.com
上述发送邮件默认会使用linux当前登陆用户信,一般会被当成垃圾邮件,指定发件人邮箱信息命令:vi /etc/mail.rc,编辑内容如:this
set from=username@163.com set smtp=smtp.163.com set smtp-auth-user=username set smtp-auth-password=yourpassword set smtp-auth=login
注意:163邮箱须要开启一个受权密码,在非163专用客户端登录都要使用受权密码登录。spa