天天看点

【主机】linux下安装sendEmail

     工作时遇到要定时获取服务器上的一个文件,所以就想到了sendemail。下面介绍一下sendemail的配置和使用:

<b>一  获取sendemail的安装包:</b>

[root@localhost ~]#<b> wget http://caspian.dotconf.net/menu/software/sendemail/sendemail-v1.56.tar.gz</b>

--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%[=================================================&gt;] 29,740      62.8k/s   in 0.5s   

20:35:52 (62.8 kb/s) - `sendemail-v1.56.tar.gz' saved [29740/29740]

<b>二 解压并进入解压的文件</b>

[root@localhost ~]# <b>tar -zxvf sendemail-v1.56.tar.gz</b> 

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 ~]# <b>cd sendemail-v1.56</b>

[root@localhost sendemail-v1.56]# ls

changelog  readme  readme-br.txt  sendemail  sendemail.pl  todo

<b>四 将sendemail 文件拷贝到/usr/local/bin 目录下,并赋与其可执行权限</b>

[root@localhost sendemail-v1.56]# <b>cp sendemail /usr/local/bin</b>

[root@localhost sendemail-v1.56]# <b>chmod  +x /usr/local/bin/sendemail</b> 

[root@localhost sendemail-v1.56]# cd ~

==修改root用户的路径path变量,使其包含sendemail(此步骤可选)

[root@localhost ~]# <b>vim .bash_profile</b>

# .bash_profile

# get the aliases and functions

if [ -f ~/.bashrc ]; then

        . ~/.bashrc

fi

# user specific environment and startup programs

path=$path:$home/bin:<b>/usr/local/bin</b>

export path

unset username

".bash_profile" 13l, 206c 已写入                                       

sendemail的常用参数:    

-m:邮件的内容,如果不带此参数,会提示用户手工输入

-f:邮件发送者

-s:stmp服务器的域名或者ip地址

-u:邮件的主题

-t:邮件接收者,如果需要发送多个,使用","隔开邮件人地址即可

-xu:表示smtp验证的用户名

-xp:smtp验证的密码

-o:文本信息字符集,若无 -o参数,发送的含有中文时会有乱码问题!

测试:

[root@localhost ~]#<b> sendemail -u "`whoami`@`hostname`: test" \</b>

<b>&gt;  -m "`whoami`@`hostname`:test"  \</b>

<b>&gt;  -f [email protected] -s 10.18.100.3:25 -t [email protected] </b>

aug 01 20:43:29 localhost sendemail[4325]: email was sent successfully!

[root@localhost ~]#  

继续阅读