linux用SendEmail发送邮件

一、下载软件
cd /usr/local/
wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz
二、解压软件
tar -zxvf sendEmail-v1.56.tar.gz
三、复制文件,并设置权限
cd sendEmail-v1.56/
cp -a sendEmail /usr/bin/
chmod +x /usr/bin/sendEmail
四、安装组件
yum -y install perl-Net-SSLeay perl-IO-Socket-SSL
五、sendEmail 命令说明

/usr/bin/sendEmail               命令主程序
-f [email protected]                 发件人邮箱
-t [email protected]                     收件人邮箱
-s smtp.163.com                  发件人邮箱的smtp服务器
-u "我是邮件主题"                邮件的标题
-a  /data/123.txt                   发送的附件绝对路径
-o message-content-type=html    邮件内容的格式,html表示它是html格式
-o message-charset=utf8         邮件内容编码
-xu [email protected]                发件人邮箱的用户名
-xp 123456                      发件人邮箱密码
-m "我是邮件内容"                 邮件的具体内容

六、发送简单的邮件

#!/bin/bash

mailserver="smtp.163.com"  #邮箱服务器地址
username_send='[email protected]'  #邮箱用户名
password='Test2018'   #邮箱密码:需要使用授权码
username_recv='[email protected]'  #收件人,多个收件人用逗号隔开
subject="SendEmail的邮件主题"  #邮件主题
body="这是SendEmail发送的邮件内容"

/usr/bin/sendEmail  -f "$username_send" -t "$username_recv" -s "$mailserver" -u "$subject" -o message-content-type=html -o message-charset=utf8 -xu "$username_send" -xp "$password" -m "$body"

七、发送带附件的邮件

#!/bin/bash

mailserver="smtp.163.com"  #邮箱服务器地址
username_send='[email protected]'  #邮箱用户名
password='Test2018'   #邮箱密码:需要使用授权码
username_recv='[email protected]'  #收件人,多个收件人用逗号隔开
subject="SendEmail的邮件主题"  #邮件主题
body="这是SendEmail发送的邮件内容"
file="/var/log/boot.log"

/usr/bin/sendEmail  -f "$username_send" -t "$username_recv" -s "$mailserver" -u "$subject" -o message-content-type=html -o message-charset=utf8 -xu "$username_send" -xp "$password" -m "$body" -a "$file"

猜你喜欢

转载自blog.csdn.net/wc1695040842/article/details/86302206
今日推荐