Chinaunix
标题:
Solaris8中用mailx发邮件到外部的邮件服务器
[打印本页]
作者:
phpasp
时间:
2008-05-31 15:54
标题:
Solaris8中用mailx发邮件到外部的邮件服务器
最近公司因项目需要,需要在一台Solaris主机发邮件到指定的邮件服务器的用户中,经过摸索后,终得解决,现将过程记录如下:
1、环境:
项目主机: IP: 192.168.1.32 OS:Solaris 8
邮件服务器:IP: 192.168.1.10 OS:Solaris 8
MTA: Postfix(需smtp验证)
DomainName: test.com HostName: mail.test.com
2、需求:即在项目主机中程序调用系统命令,发邮件给邮件服务器的一些用户.
3、修改项目主机中一些文件(注意红色部分):
cat /etc/hosts
#
# Internet host table
#
127.0.0.1 localhost
192.168.1.32 Pj loghost
192.168.1.10 mail.test.com
/etc/mail/sendmail.cf文件中以下两行改成如下:
#Dj$w.Foo.COM
Dj$w.
test.com
CP.
# "Smart" relay host (may be null)
#DSmailhost$?m.$m$.
DS
m
ail.test.com
然后重启一下sendmail(本想restart,居然没有)
#/etc/init.d/sendmail stop
#/etc/init.d/sednmail start
4、测试发邮件,如果正确,即可收到邮件,有关命令mailx的详细使用,请参考man mailx:
echo "test" | mailx -r
test-a@test.com
-s "test-solaris"
test-b@test.com
5、排错
如没有收到邮件,在项目主机中执行mail,看看是否有系统的退信,再根据退信的原因查找,如reason: 501 5.1.7 Bad sender address syntax;再到邮件服务器上查找邮件的日志,是否有错误,如warning: Illegal address syntax from unknown等,然后再根据这些错误来解决。
以上过程在我的环境中测试成功。
本文来自ChinaUnix博客,如果查看原文请点:
http://blog.chinaunix.net/u/16464/showart_721257.html
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2