shell下脚本实现发送邮件
来源:互联网 发布:数据堂怎么兼职 编辑:程序博客网 时间:2024/06/16 07:46
Shell脚本实现自动发邮件
- 博客分类:
- 脚本编程
1、编辑用户Home目录下的.muttrc文件,设置发信环境。(可不做)
- # cat /root/.muttrc
- set envelope_from=yes
- set from=owinux@sina.cn
- set realname="Owinux"
- set use_from=yes
- set rfc2047_parameters=yes
- set charset="utf-8"
3、简要说明:
[root@stb mapreduce]# cat map_shell_mail.sh
#!/bin/bash
#
# send mail to fangchong@cucrz.com
#
from_name="fangchong@cuc-rz.com"
DATE=`date +%Y%m%d`
DATEM=`date +%Y-%m-%d"日 "%k:%M`
results=`tail -1 /home/mapreduce/$DATE-mapreduce.log`
sed -e 's/$/\r/' /home/mapreduce/$DATE-mapreduce.log > /home/mapreduce/$DATE-mapreduces.log
email_content=/home/mapreduce/$DATE-mapreduces.log
temp=/home/mapreduce/temp.txt
echo " $DATEM 开始检查 " &> $temp
echo " " &>> $temp
echo " " &>> $temp
echo " $results" &>> $temp
echo " " &>> $temp
echo " 附件成功结果,请注意查收 " &>> $temp
cat /home/mapreduce/temp.txt | mail -s " mapreduce The execution result report " -a $email_content $from_name
-s:指定主题
-a:附件
-c:抄送,需要抄送多人的话,须使用多个 -c 选项
使用上面的发信环境可以保证在页面查看邮件的时候,附件名不出现乱码。
其中 .muttrc 的 "set from"可以随便设置,可以是不存在的邮箱地址,当然正确的最好。
比如:
- set from=abc@owinux.com
不过也并不是你设置的正确的邮箱地址就一定能发送成功。
- set from=owinux@126.com
我新注册了一个 owinux@126.com,然后将 set from 设置为owinux@126.com,就没有成功。
原因在于126邮箱报了 550 MI:SPF 错误,连接到126 企业退信的常见问题? 发现
- 550 MI:SPF 发信IP未被发送域的SPF许可。
![](http://dl.iteye.com/upload/attachment/0075/9946/2095daf6-c2ed-3468-8459-fa8815dd7c02.png)
- shell下脚本实现发送邮件
- Linux下脚本实现交互输入
- 用linux shell实现邮件发送功能
- windows下脚本若干问题
- ubuntu下脚本基础
- shell的发送邮件
- linux shell发送邮件
- linux shell 发送邮件
- 浅析linux下脚本拨号上网
- linux下脚本中多行注释
- uboot 下脚本的开发
- linux 下脚本运行php
- linux下脚本书写注意事项
- uboot 下脚本的开发
- ubuntu下脚本学习记录
- uboot 下脚本的开发
- Linux下脚本对拍
- linux下脚本的创建
- JNI调用机制
- PB数据窗口导出excel,修改第一行英文标题为中文标题,计算合计值
- 公式 集锦
- 不会用ant打包、部署项目的工程师,不是一个好程序员(测试)
- Challenges and solutions - Architecture of a Modern Web Application
- shell下脚本实现发送邮件
- 四件在我步入职业软件开发生涯那天起就该知道的事情
- printf转义字符表
- ext/curl/.libs/interface.o: undefined reference to symbol 'CRYPTO_set_id_callback'
- 赛车要不要加油
- QQ黑客技术20招
- printf函数使用时的注意事项
- java常用并发工具介绍
- poj 3682 King Arthur's Birthday Celebration(数学期望)