在linux发送邮件须要两个程序,分别是mutt和smstp。前者是mail的客户端User,后者则是个smtp的简易服务器,要发邮件二者不可或缺(固然也能够经过其余工具来发送) html
能够经过如下方式查看 linux
[root@localhost ~]# rpm -qa|grep mutt mutt-1.4.2.2-3.0.2.el5 [root@localhost ~]#
smstp通常去/usr/local/bin或者/usr/bin等路径下find一把 服务器
[root@localhost bin]# ll total 240 -rwxr-xr-x 1 root root 237267 Apr 10 03:36 msmtp
若是没有安装,则能够用rpm -ivh mutt-1.4.2.2-3.0.2.el5.x86_64.rpm 来安装 工具
smstp则能够在http://download.chinaunix.net/download/0008000/7048.shtml下载。 spa
系统这边已经安装了mutt,只须要下载个smstp而后安装便可。 .net
安装的步骤是 unix
[root@localhost ~]# cd msmtp-1.4.5 code
[root@localhost ~]# ./configure htm
[root@localhost ~]# make get
[root@localhost ~]# make install
本次安装开始下载的是msmtp-1.4.27版本,可是编译的时候报了一个错误:
[root@localhost msmtp-1.4.27]# make make all-recursive make[1]: Entering directory `/root/msmtp-1.4.27' Making all in src make[2]: Entering directory `/root/msmtp-1.4.27/src' CCLD msmtp tls.o: In function `tls_init':/root/msmtp-1.4.27/src/tls.c:1100: undefined reference to `gnutls_priority_set_direct' collect2: ld returned 1 exit status make[2]: *** [msmtp] Error 1 make[2]: Leaving directory `/root/msmtp-1.4.27/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/root/msmtp-1.4.27' make: *** [all] Error 2
无解,后来听朋友说换一个低版本的安装,结果未报错。选择了版本msmtp-1.4.5
邮件的发送:
[root@localhost ~]# echo "Believing the god with U"|mutt -s "keyon's mail" xxxxx@163.com [root@localhost ~]#
去指定的邮箱查看,收到了主题为keyon's mail,内容为Believing the god with U的邮件。
若要增长附件,则加上-a参数,如当前目录:
[root@localhost ~]# ll total 584 -rw------- 1 root root 1464 Apr 9 05:55 anaconda-ks.cfg drwxr-xr-x 2 root root 4096 Apr 9 22:44 Desktop -rw-r--r-- 1 root root 52465 Apr 9 05:55 install.log -rw-r--r-- 1 root root 4728 Apr 9 05:55 install.log.syslog drwxrwxrwx 6 1000 1000 4096 Apr 10 03:36 msmtp-1.4.5-rw-r--r-- 1 root root 489336 Apr 9 19:37 msmtp-1.4.5.tar.bz2
发送install.log.syslog文件出去。
[root@localhost ~]# echo "Believing the god with U"|mutt -a install.log.syslog -s "keyon's mail" lqchenzjut@163.com [root@localhost ~]#
检查,OK。
若要发送多人,则能够在各个收件人邮箱之间以逗号区分便可。