Centos下安装mailx

[root@localhost /]# mail -s "Message" xxxxx@163.com < /tmp/info.message


系统认以“root@主机名” 发送邮件,收到邮件直接被过虑成垃圾邮件了,那可不可以自定义邮箱发送邮件呢?

答案肯定可以的。

下载mailx包

mailx官方站点 http://heirloom.sourceforge.net/

下载最新版本mailx-12.4.tar.bz2 (271.5 kB)

http://sourceforge.net/projects/heirloom/files/latest/download?source=files

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
[root@localhostsoftware] #tar-jxvfmailx-12.4.tar.bz2
#cdmailx-12.4
[root@localhostmailx-12.4] #make
openssl.c:108:错误:expecteddeclarationspecifiersor‘...’before‘STACK’
openssl.c:在函数‘ssl_select_method’中:
openssl.c:215:警告:赋值丢弃了指针目标类型的限定
openssl.c:217:警告:赋值丢弃了指针目标类型的限定
openssl.c:219:警告:赋值丢弃了指针目标类型的限定
openssl.c:223:警告:赋值丢弃了指针目标类型的限定
openssl.c:226:警告:赋值丢弃了指针目标类型的限定
openssl.c:在函数‘ssl_check_host’中:
openssl.c:311:错误:‘STACK’未声明(在此函数内第一次使用)
openssl.c:311:错误:(即使在一个函数内多次出现,每个未声明的标识符在其
openssl.c:311:错误:所在的函数内也只报告一次。)
openssl.c:311:错误:‘gens’未声明(在此函数内第一次使用)
openssl.c:在文件层:
openssl.c:499:错误:expecteddeclarationspecifiersor‘...’before‘STACK’
openssl.c:在函数‘smime_verify’中:
openssl.c:508:错误:‘STACK’未声明(在此函数内第一次使用)
openssl.c:508:错误:‘certs’未声明(在此函数内第一次使用)
openssl.c:508:错误:‘gens’未声明(在此函数内第一次使用)
openssl.c:555:错误:‘chain’未声明(在此函数内第一次使用)
openssl.c:在函数‘cverify’中:
openssl.c:617:错误:‘STACK’未声明(在此函数内第一次使用)
openssl.c:617:错误:‘chain’未声明(在此函数内第一次使用)
openssl.c:649:错误:提供给函数‘smime_verify’的实参太多
openssl.c:在函数‘smime_encrypt’中:
openssl.c:690:错误:‘STACK’未声明(在此函数内第一次使用)
openssl.c:690:错误:‘certs’未声明(在此函数内第一次使用)
openssl.c:在函数‘smime_certsave’中:
openssl.c:953:错误:‘STACK’未声明(在此函数内第一次使用)
openssl.c:953:错误:‘certs’未声明(在此函数内第一次使用)
openssl.c:955:错误:‘chain’未声明(在此函数内第一次使用)
Makefile:80:recipe for target 'openssl.o' Failed
make :***[openssl.o]Error1

出现错误,看下面文档帮助

http://www.linuxfromscratch.org/blfs/view/stable/basicnet/mailx.html

原来差补丁,修复他

4
#wgethttp://www.linuxfromscratch.org/patches/blfs/7.6/mailx-12.4-openssl_1.0.0_build_fix-1.patch
#patch-Np1-imailx-12.4-openssl_1.0.0_build_fix-1.patch
patching file makeconfig
openssl.c

#修复补丁成功

14
#makeclean#清除历史编译后文件
#make#再次编绎
#makeinstallUCBINSTALL=/usr/bin/install
/usr/bin/install -cmailx /usr/local/bin/mailx
strip /usr/local/bin/mailx
test -d /usr/local/share/man/man1 || mkdir -p /usr/local/share/man/man1
-c-m644mailx.1 /usr/local/share/man/man1/mailx .1
/etc /etc
-f /etc/nail .rc||\
-c-m644nail.rc .rc
[root@localhostbin] #vim/etc/nail.rc#编辑nail.rc配置外部SMTP信息
set from=xxxx@163.comsmtp=smtp.163.com
smtp-auth-user=xxxxx@163.comsmtp-auth-password=xxxxxsmtp-auth=login
#servicepostfixreload#重新加载postfix,可以不用重启的。

测试一下

1
#mail-s"Message"xxxxx@163.com</tmp/info.message

邮件发送成功,但为什么收到的还是root@localhost.xx发送的邮件呢?

2
#whereismailx
mailx: /bin/mailx /usr/bin/mailx /usr/local/bin/mailx /usr/share/man/man1/mailx .1 .1.gz /usr/share/man/man1p/mailx .1p.gz

哦,原因是新安装的包没有生效,执行还是原来的路径,替换他。

5
#cd/bin
#rm-rfmailx
#ln-s/usr/local/bin/mailxmailx
#mailx-V
这下成功。

其它方法如:SendEmail 见http://caspian.dotconf.net/menu/Software/SendEmail/

相关文章

Centos下搭建性能监控Spotlight
CentOS 6.3下Strongswan搭建IPSec VPN
在CentOS6.5上安装Skype与QQ
阿里云基于centos6.5主机VPN配置
CentOS 6.3下配置multipah
CentOS安装、配置APR和tomcat-native