Operating System - Linux
1753370 Members
5087 Online
108792 Solutions
New Discussion

sendmail can not relay mail to exchange server

 
Arunabha Banerjee
Valued Contributor

sendmail can not relay mail to exchange server

My goal is to be able to send all email through my Linux server using sendmail, to Exchange Server. I have added Exchange Server entry in /etc/mail/sendmail.cf file but still it is relaying to localhost.localdomain.

 

Red Hat OS

 

 

[root@vburplsmtp06 root]# cat /etc/redhat-release
Red Hat Enterprise Linux ES release 3 (Taroon Update 8)

 

 sendmail version

 

 

[root@vburplsmtp06 root]# rpm -qa | grep -i sendmail*
sendmail-cf-8.12.11-4.RHEL3.6
sendmail-8.12.11-4.RHEL3.6

 

RelayHost entry in sendmail.cf file

 

 

[root@vburplsmtp06 root]# cat /etc/mail/sendmail.cf | grep -e DS
DSmailhost
# Return-Receipt-To: header implies DSN request
# DHParameters (only required if DSA/DH is used)

 

/etc/hosts file

 

 

[root@vburplsmtp06 mail]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain   localhost
146.178.24.70   vburplsmtp06    mail2.alinta.net.au
146.178.73.228  mailhost

 

resolv.conf

 

 

[root@vburplsmtp06 root]# cat /etc/resolv.conf
domain alinta.net.au
search alinta.net.au ue.com.au
nameserver 218.185.65.254
nameserver 203.94.140.38
nameserver 203.94.129.130
nameserver 146.178.22.217
nameserver 146.178.73.217

 

 

/var/log/maillog output

 

 

 

Aug 13 21:29:41 vburplsmtp06 sm-msp-queue[19707]: p7D6jqcT014362: p7DBQp1j019707: sender notify: Warning: could not send message for past 4 hours
Aug 13 21:29:41 vburplsmtp06 sendmail[19734]: alias database /etc/aliases.db out of date
Aug 13 21:29:41 vburplsmtp06 sendmail[19734]: p7DBSiEX019734: from=<>, size=10664, class=0, nrcpts=1, msgid=<201108131129.p7DBQp1j019707@mail2.alinta.net.au>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]

 

Tried to send mail manually and it is pointing relayhost to localhost.localdomain

 

 

[root@vburplsmtp06 root]# sendmail -v root
test
.
root... Connecting to [127.0.0.1] via relay...
220 mail2.alinta.net.au ESMTP Sendmail 8.12.11.20060308/8.12.11; Sat, 13 Aug 2011 20:48:54 +1000
>>> EHLO mail2.alinta.net.au
250-mail2.alinta.net.au Hello localhost.localdomain [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH GSSAPI
250-DELIVERBY
250 HELP
>>> MAIL From:<abanerjee@mail2.alinta.net.au> SIZE=5 AUTH=abanerjee@mail2.alinta.net.au
250 2.1.0 <abanerjee@mail2.alinta.net.au>... Sender ok
>>> RCPT To:<root@mail2.alinta.net.au>
>>> DATA
250 2.1.5 <root@mail2.alinta.net.au>... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .
250 2.0.0 p7DAmsYo019039 Message accepted for delivery
root... Sent (p7DAmsYo019039 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 mail2.alinta.net.au closing connection

 

 Tried to send mail manually through Exchange Server (mailhost - 146.178.73.228) and I got the mail in my mailbox.

 

 

[root@vburplsmtp06 root]# telnet mailhost 25
Trying 146.178.73.228...
Connected to mailhost (146.178.73.228).
Escape character is '^]'.
220 VTALPWSMTP05.alinta.net.int Microsoft ESMTP MAIL Service, Version: 6.0.3790.4675 ready at  Sat, 13 Aug 2011 21:49:41 +1000
HELO
250 VTALPWSMTP05.alinta.net.int Hello [146.178.24.70]
MAIL FROM: root@vburplsmtp06
250 2.1.0 root@vburplsmtp06....Sender OK
RCPT TO: barunab@maxis.com.my
250 2.1.5 barunab@maxis.com.my
DATA
354 Start mail input; end with <CRLF>.<CRLF>
This is a test mail
.
250 2.6.0 <VTALPWSMTP05WEsBk310000137e@VTALPWSMTP05.alinta.net.int> Queued mail for delivery
QUIT
221 2.0.0 VTALPWSMTP05.alinta.net.int Service closing transmission channel
Connection closed by foreign host.

 

So why sendmail is always pointing "relay=localhost.localdomain [127.0.0.1]" why not "mailhost" after adding the "DSmailhost" entry

Please help.

AB
8 REPLIES 8
Naj
Valued Contributor

Re: sendmail can not relay mail to exchange server

Hi,

Could you please paste configuration for

#more /etc/mail/access

Thanks

BR
Naj

____________________________________________
:: Really appreciate if you could assign some points.
:: Don't know how to assign point? Click the KUDOS! star!
Arunabha Banerjee
Valued Contributor

Re: sendmail can not relay mail to exchange server

Please find /etc/mail/access entry as below

 

[root@vburplsmtp06 root]# cat /etc/mail/access
# Check the /usr/share/doc/sendmail/README.cf file for a description
# of the format of this file. (search for access_db in that file)
# The /usr/share/doc/sendmail/README.cf is part of the sendmail-doc
# package.
#
# by default we allow relaying from localhost...
localhost.localdomain           RELAY
localhost                       RELAY
127.0.0.1                       RELAY

 

 

AB
Naj
Valued Contributor

Re: sendmail can not relay mail to exchange server

Hi,

 

How about sendmail.mc file configuration, did you add relay server there?

 

#vi sendmail.mc

dnl define(`SMART_HOST',`smtp.your.provider')dnl

 

replace your mail exchange server as below

define(`SMART_HOST',`exchange-server name')

 

::save configuration

 

# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

 

Thanks

 

BR

Naj


____________________________________________
:: Really appreciate if you could assign some points.
:: Don't know how to assign point? Click the KUDOS! star!
Arunabha Banerjee
Valued Contributor

Re: sendmail can not relay mail to exchange server

This entry I have added already.

 

[root@vburplsmtp06 mail]# cat sendmail.mc | grep -e mailhost
define(`SMART_HOST',`mailhost')
[root@vburplsmtp06 mail]#

 

AB
Matti_Kurkela
Honored Contributor

Re: sendmail can not relay mail to exchange server

In /etc/hosts, you have told "mail2.alinta.net.au" is an alias for vburplsmtp06.

 

Your test message is addressed to "abanerjee@mail2.alinta.net.au". Because the destination hostname matches one of the aliases of the local host, our sendmail will notice this is supposed to be a local recipient, so there is no reason to use a smarthost. It will attempt to deliver the mail locally, typically to Unix mailbox file /var/mail/abanerjee (assuming that such an user exists on the system).

 

The "forwarding to localhost" happens because in RHEL 3 and newer, Sendmail runs as two separate processes:

# ps -ef |grep send
root      4078     1  0 Jul04 ?        00:01:59 sendmail: accepting connections
smmsp     4087     1  0 Jul04 ?        00:00:00 sendmail: Queue runner@01:00:00 

 All the messages are first forwarded to the local Sendmail queue runner process, which will then make the necessary outgoing connections and/or invoke the local delivery agent as necessary.

 

If you want absolutely all mail (even the messages addressed to local recipients) to go to exchange server, you should add

define(`MAIL_HUB',`mailhost')

 to your sendmail.mc, and then regenerate your sendmail.cf using these commands:

cd /etc/mail
make

 (The /etc/mail/Makefile contains instructions for the "make" command, including the correct m4 command line for regenerating the sendmail.cf using the sendmail.mc as a template.)

 

Sendmail's logic works out like this:

  1. Is MAIL_HUB set? If yes, send message to MAIL_HUB server for further delivery; otherwise continue.
  2. Is the destination address local? If yes, then deliver locally; otherwise continue.
  3. Is SMART_HOST set? If yes, send message to SMART_HOST server for further delivery; otherwise continue.
  4. (all the other steps required to find and contact a remote mail server over the Internet)

If you use MAIL_HUB, your Exchange server must be prepared to accept and handle incoming messages addressed to destinations like "root@mail2.alinta.net.au", "root@vburplsmtp06" or maybe even just "root" in some meaningful fashion.

MK
Arunabha Banerjee
Valued Contributor

Re: sendmail can not relay mail to exchange server

Hi Matti,

 

Thanks for the explantaion. But after implementing the steps "define(`MAIL_HUB',`mailhost')" still I am facing the same problem.

 

 

AB
Wilfred Chau_1
Respected Contributor

Re: sendmail can not relay mail to exchange server

If you use an IP of the exchange server for the DS directive, can you relay mail?

tuxy
Occasional Visitor

Re: sendmail can not relay mail to exchange server

Did you resolved the problem or it is still appears?