linux下安装sendEmail
sendEmail 是一个邮件代理传输程序,当sendmail程序得到一封待发送的邮件的时候,它需要根据目标地址确定将信件投递给对应的服务器,这是通过DNS服务实现的。例如一封邮件的目标地址是yangql@163.com,那么sendmail首先确定这个地址是用户名(yangql)+机器名(163.com)的格式,然后,通过查询DNS来确定需要把信件投递给某个服务器。
工作时遇到要定时获取服务器上的一个文件,所以就想到了sendEmail。下面介绍一下sendEmail的配置和使用:
一 获取sendEmail的安装包:
[root@localhost ~]#wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz
--20:35:50-- http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz
正在解析主机 caspian.dotconf.net... 69.164.196.234
Connecting to caspian.dotconf.net|69.164.196.234|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:29740 (29K) [application/x-gzip]
Saving to: `sendEmail-v1.56.tar.gz'
100%[=================================================>] 29,740 62.8K/s in 0.5s
20:35:52 (62.8 KB/s) - `sendEmail-v1.56.tar.gz' saved [29740/29740]
二 解压并进入解压的文件
[root@localhost ~]#tar -zxvf sendEmail-v1.56.tar.gz
sendEmail-v1.56/
sendEmail-v1.56/CHANGELOG
sendEmail-v1.56/README
sendEmail-v1.56/README-BR.txt
sendEmail-v1.56/TODO
sendEmail-v1.56/sendEmail
sendEmail-v1.56/sendEmail.pl
[root@localhost ~]#cd sendEmail-v1.56
[root@localhost sendEmail-v1.56]# ls
CHANGELOG README README-BR.txt sendEmail sendEmail.pl TODO
四 将sendEmail 文件拷贝到/usr/local/bin 目录下,并赋与其可执行权限
[root@localhost sendEmail-v1.56]#cp sendEmail /usr/local/bin
[root@localhost sendEmail-v1.56]#chmod +x /usr/local/bin/sendEmail
[root@localhost sendEmail-v1.56]# cd ~
==修改root用户的路径PATH变量,使其包含sendEmail(此步骤可选)
[root@localhost ~]#vim .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/usr/local/bin
export PATH
unset USERNAME
".bash_profile" 13L, 206C 已写入
sendEmail的常用参数:
-m:邮件的内容,如果不带此参数,会提示用户手工输入
-f:邮件发送者
-s:STMP服务器的域名或者IP地址
-u:邮件的主题
-t:邮件接收者,如果需要发送多个,使用","隔开邮件人地址即可
-xu:表示SMTP验证的用户名
-xp:SMTP验证的密码
-o:文本信息字符集,若无 -o参数,发送的含有中文时会有乱码问题!
测试:
[root@localhost ~]#sendEmail -u "`whoami`@`hostname`: test"
> -m "`whoami`@`hostname`:test"
> -f qilong.yang@yangql.com -s 10.18.100.3:25 -t yangql@163.com
Aug 01 20:43:29 localhost sendEmail[4325]:Email was sent successfully!