使用Shell脚本写邮件

[[email protected] ~]# wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz


[[email protected] ~]# clear
[[email protected] ~]# mkdir -p /usr/local/bin
[[email protected] ~]# tar zxf sendEmail-v1.56.tar.gz -C /usr/src/
[[email protected] ~]# cd /usr/src/sendEmail-v1.56/
[[email protected] sendEmail-v1.56]# cp -a sendEmail /usr/local/bin/
[[email protected] sendEmail-v1.56]# chmod +x /usr/local/bin/sendEmail
[[email protected] sendEmail-v1.56]# yum install perl-Net-SSLeay perl-IO-Socket-SSL -y

[[email protected] sendEmail-v1.56]# clear
[[email protected] sendEmail-v1.56]# cd 
[[email protected] ~]# mkdir email
[[email protected] ~]# cd email/

[[email protected] email]# vi sEmail


#!/bin/bash

#收件箱
EMAIL_RECIVER="[email protected]"
#发送者邮箱
[email protected]
#邮箱用户名
EMAIL_USERNAME=508529886
#邮箱密码
#使用qq邮箱进行发送需要注意:首先需要开启:POP3/SMTP服务,其次发送邮件的密码需要使用在开启POP3/SMTP服务时候腾讯提供的第三方客户端登陆码。
EMAIL_PASSWORD=htsihblikjodcafb

#附件路径
FILE1_PATH="/root/anaconda-ks.cfg"

#smtp服务器地址
EMAIL_SMTPHOST=smtp.qq.com

EMAIL_TITLE="测试"
EMAIL_CONTENT="Hello Spark"

sendEmail -f ${EMAIL_SENDER} -t ${EMAIL_RECIVER} -s ${EMAIL_SMTPHOST} -u ${EMAIL_TITLE} -xu ${EMAIL_USERNAME} -xp ${EMAIL_PASSWORD} -m ${EMAIL_CONTENT} -a ${FILE1_PATH} -o message
-charset=utf-8


[[email protected] email]# chmod + sEmail 
[[email protected] email]# ll
total 4
-rw-r--r-- 1 root root 732 Apr 13 11:04 sEmail
[[email protected] email]# chmod +x sEmail 
[[email protected] email]# ./sEmail 
Apr 13 11:04:52 node03 sendEmail[1287]: Email was sent successfully!

注意:使用qq邮箱进行发送需要注意:首先需要开启:POP3/SMTP服务,其次发送邮件的密码需要使用在开启POP3/SMTP服务时候腾讯提供的第三方客户端登陆码。

使用Shell脚本写邮件

使用Shell脚本写邮件