在Red Hat上configuration邮件中继

我有一个红帽子Linux服务器,不能发送传出的电子邮件。 我也有一个solaris服务器,之前已经configuration邮件中继邮件服务器。 为了使用户能够从红帽子接收邮件,我需要通过solaris服务器中继邮件。 而且我的老板严格地要求我用sendmail代替postfix。

到目前为止,这是我做的:

solaris服务器:bres.net.com – 192.65.7.8

红帽子:主机名:蝙蝠侠IP:192.55.7.43

编辑/etc/mail/sendmail.mc

define(`SMART_HOST',`bres.net.com')dnl MASQUERADE_AS(`net.com')dnl FEATURE(masquerade_envelope)dnl FEATURE(masquerade_entire_domain)dnl MASQUERADE_DOMAIN(localhost)dnl MASQUERADE_DOMAIN(localhost.net.com)dnl MASQUERADE_DOMAIN(batman.net.com)dnl MASQUERADE_DOMAIN(others.net.com)dnl 

编辑/ etc / hosts

 127.0.0.1 batman.net.com localhost.localdomain localhost batman 192.55.7.43 batman batman.net.com loghost 192.65.7.8 bres bres.net.com 

编辑/etc/resolv.conf

 search net.com bres.net.com 192.65.7.8 

创build新的sendmail.cf:

 m4 sendmail.mc > sendmail.cf 

重新启动sendmail

尝试发送邮件进行testing

检查日志/ var / log / maillog

 Nov 22 12:00:54 localhost sendmail[22251]: uAM402ru022251: from=root, size=591, class=0, nrcpts=1, msgid=<[email protected]>, relay=root@localhost Nov 22 12:02:54 localhost sendmail[22281]: uAM40sRm022281: from=<[email protected] >, size=863, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA, relay=batman.net.com[127.0.0.1] Nov 22 12:02:54 localhost sendmail[22251]: uAM402ru022251: to=root, ctladdr=root (0/0), delay=00:02:52, xdelay=00:02:00, mailer=relay, pri=30591, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (uAM40sRm022281 Message accepted for delivery) Nov 22 12:04:14 localhost sendmail[22303]: uAM40sRm022281: to=<[email protected]>, delay=00:01:20, xdelay=00:01:20, mailer=relay, pri=120863, relay=bres.net.com, dsn=4.0.0, stat=Deferred: Name server: bres.net.com: host name lookup failure 

更改后定义( SMART_HOST', 192.65.7.8')dnl =,日志显示如下:

 Nov 23 09:51:49 batman sendmail[8953]: uAN1m5aZ008953: from=<[email protected]>, size=1052, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA, relay=batman.net.com [127.0.0.1] Nov 23 09:51:49 batman sm-msp-queue[8950]: uAMM02K3007934: to=root, ctladdr=root (0/0), delay=03:51:47, xdelay=00:03:44, mailer=relay, pri=120780, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (uAN1m5aZ008953 Message accepted for delivery) Nov 23 09:51:49 batman sendmail[8964]: uAN1m5aZ008953: to=<[email protected]>, ctladdr=<[email protected]> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31276, dsn=2.0.0, stat=Sent Nov 23 09:51:49 batman sendmail[8953]: uAN1m5ab008953: from=<[email protected]>, size=3002, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA, relay=batman.net.com [127.0.0.1] Nov 23 09:51:49 batman sm-msp-queue[8950]: uAMK2UOH007318: to=root, ctladdr=root (0/0), delay=05:49:19, xdelay=00:00:00, mailer=relay, pri=122704, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (uAN1m5ab008953 Message accepted for delivery) Nov 23 09:51:49 batman sendmail[8966]: uAN1m5ab008953: to=<[email protected]>, ctladdr=<[email protected]> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=33231, dsn=2.0.0, stat=Sent Nov 23 09:54:11 batman sendmail[8962]: uAN1oRWw008962: from=root, size=66, class=0, nrcpts=1, msgid=<[email protected]>, relay=root@localhost Nov 23 09:54:11 batman sendmail[8962]: uAN1oRWw008962: [email protected], delay=00:03:44, mailer=esmtp, pri=30066, dsn=4.4.3, stat=queued 

我可以通过改变定义的SMARTHOST中继电子邮件,并添加一个configuration文件(service.switch)在etc / mail。

 define(`SMART_HOST',`relay:[192.65.7.8]')dnl 

在etc / mail中添加service.switch

 ####### start of file ######### hosts files aliases files ####### end of file ########### 

更改后,邮件中继工作得很好。 但红帽服务器重启后,sendmail不能正常工作,日志显示如下:

 Nov 25 10:00:30 batman sendmail[15372]: uAP20Ude015372: from=root, size=66,class=0, nrcpts=1, msgid=<[email protected]>, relay=root@localhost Nov 25 10:00:30 batman sendmail[15372]: uAP20Ude015372: [email protected], ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30066,relay=[127.0.0.1] [127.0.0.1], dsn=4.0.0, stat=Deferred: Connection refused by [127.0.0.1] 

在这个日志之前,日志显示:

 Nov 24 10:09:47 batman sendmail[24936]: uAO29kOL024936: ruleset=check_rcpt, arg1=<[email protected]>, relay=[192.65.7.8], reject=450 4.4.0 <[email protected]>... Relaying temporarily denied. Cannot resolve PTR record for 192.65.7.8 

日志显示连接被拒绝,无法parsingPTRlogging。 请帮忙。

“主机名称查找失败”表示一个DNS错误,不一定是一个sendmail错误configuration。

Sendmail,或者更确切地说依靠发送电子邮件取决于DNS,并且与仅作为/etc/hosts文件中的条目存在的主机和域不兼容。

最简单的方法是确保nslookup bres.net.com正常工作。

也许这是你的问题的格式,但条目bres.net.com 192.65.7.8不属于resolv.conf并且在那里也应该有一个nameserver <IP-address of nameserver> 。 一个简单的resolv.conf如下所示:

 #/etc/resolv.conf domain example.com search example.com nameserver 8.8.8.8 options attempts:2 

您可以尝试使用智能主机的IP地址而不是主机名,以避免一些DNS问题:

 define(`SMART_HOST',`[192.65.7.8]')dnl