阿里云服务器centOS发送邮件(阿里云服务器封闭了25端口)
安装邮件服务
yum install mailx -y
如果出现错误:
send-mail: warning: inet_protocols: IPv6 support is disabled错误解决
原因是不支持IPV6
解决方式如下:
查看协议信息
/usr/sbin/postconf | grep inet_protocols
inet_protocols = all
修改如下:
vim /etc/postfix/main.cf
inet_protocols = all 修改为 inet_protocols = ipv4
然后重启postfix
/etc/init.d/postfix restart
即可
编辑
vim /etc/mail.rc
增加一下内容:
set from=your_send_email@163.com
set smtp=smtps://smtp.163.com:465
set smtp-auth-user=your_send_email@163.com
set smtp-auth-password=your_password
set smtp-auth=login
set ssl-verify=ignore
set nss-config-dir=/etc/pki/nssdb/
保存完毕。
执行,命令行输入状态,此时可以输入内容,按Ctrl+d键来结束输入
mail -v -s “test” your_receive_email@163.com
或者
mailx -v -s “test” your_receive_email@163.com
发送文件内容,例如文件内容存储在msg文件内
mailx -s “test mail” your_receive_email@163.com < msg
或者
cat msg | mails -s “test” your_receive_email@163.com
多个收件人之间用逗号分隔
cat msg | mails -s “test” your_receive_email@163.com,your_receive_email@163.com
其他选项
-r 指定发件人
-c 指定抄送人
-b 指定密送人
多个收件人之间用逗号分隔