linux系统mail测试脚本

作者: admin 分类: Shell脚本 发布时间: 2020-08-28 15:40
[root@qunniao ~]# vim mail_test.sh
#!/bin/bash

MAIL_FROM='lnhxzwb@126.com'
MAIL_TO=$1
MAIL_SUBJECT=$2
MAIL_CONTENT=$3
MAIL_CONTENT_FILE="/tmp/$(data +%s).txt"
MAIL_SMTP='smtp://smtp.126.com'
MAIL_USER='lnhxzwb@126.com'
MAIL_PASSWORD='password'
# create mail content file
echo -e "From:${MAIL_FROM}
To:$1
Subject: $MAIL_SUBJECT
$MAIL_CONTENT " > ${MAIL_CONTENT_FILE}
# send mail
curl -s --url "${MAIL_SMTP}" --mail-from "${MAIL_FROM}" --mail-rcpt ${MAIL_TO} \
--upload-file ${MAIL_CONTENT_FILE} --user "${MAIL_USER}:${MAIL_PASSWORD}"
[root@qunniao ~]# chmod +x  mail_test.sh
[root@qunniao ~]# mail_test.sh xxxx@xx.com  "邮件标题"  "邮件内容"




温馨提示:如无特殊说明,本站文章均为作者原创,转载请注明出处!

发表评论