LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Forward root mail to external account requering smtp authentication.... (https://www.linuxquestions.org/questions/linux-server-73/forward-root-mail-to-external-account-requering-smtp-authentication-842228/)

fcintron 11-03-2010 08:59 PM

Forward root mail to external account requering smtp authentication....
 
Well this is my problem .

I have one Centos Server and I want to forward root mail to 1 external account: she@example.com.

I installed sendmail and created /root/.forward with this content:

she@example.com

and I sent a test mail with this command:

/usr/sbin/sendmail root <prueba.txt

But nothing was forwarded.


After that I ran the same command with the verbose option:

/usr/sbin/sendmail -v root <prueba.txt

And this is the output:


root... Connecting to [127.0.0.1] via relay...
220 localhost.localdomain ESMTP Sendmail 8.13.8/8.13.8; Wed, 3 Nov 2010 21:09:39 -0600
>>> EHLO localhost.localdomain
250-localhost.localdomain Hello myfriend [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5
250-DELIVERBY
250 HELP
>>> MAIL From:<me@localhost.localdomain> SIZE=109 AUTH=me@localhost.localdomain
250 2.1.0 <me@localhost.localdomain>... Sender ok
>>> RCPT To:<me@localhost.localdomain>
>>> DATA
250 2.1.5 <root@localhost.localdomain>... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .
250 2.0.0 oA439d8W005554 Message accepted for delivery
root... Sent (oA439d8W005554 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 localhost.localdomain closing connection
[oracle@bdd ~]$

This means that sendmail is accepting my mail and queuing it for delivering.

This message is being written in my /var/log/maillog when sendmail try to forward root email:


Nov 3 21:23:25 server sendmail[6127]: oA43LMIw006126: to=she@example.com, ctladdr=<me@localhost.localdomain> (500/501), delay=00:02:03, xdelay=00:02:02, mailer=esmtp, pri=30593, relay=example.com. [69.175.94.106], dsn=4.0.0, stat=Deferred: Connection timed out with example.com.


For some reason sendmail tried to connect to example.com smtp server and couldn't reach it.

I am sure this is because the smtp server for example.com domain is not example.com is mail.example.com. Besides mail.example.com requires authentication, username , password and the smtp port is not the default 25 is 9999.

May you help me to configure sendmail to forward root mail to a smtp server that requires authentication, username, password with a not the default 25 port?

Thanks in advance

quanta 11-03-2010 09:31 PM

Hi,

This may help. You can change the default port with:
Code:

define(`RELAY_MAILER_ARGS', `TCP $h 9999')
define(`ESMTP_MAILER_ARGS', `TCP $h 9999')


amlife 11-03-2010 11:46 PM

uhhh, why do you have to go through all this trouble??

simply as an alias to root with your external email address!

vim /etc/aliases & scroll to the very bottom & type
root she@example.com

when done, save your changes and do

source /etc/aliases or newaliases

now all emails destined to root will be also sent to the external email address!

That is all!

cheers

repo 11-04-2010 05:09 AM

Quote:

Originally Posted by amlife (Post 4148709)
uhhh, why do you have to go through all this trouble??
simply as an alias to root with your external email address!
vim /etc/aliases & scroll to the very bottom & type
root she@example.com
when done, save your changes and do
source /etc/aliases or newaliases
now all emails destined to root will be also sent to the external email address!
That is all!
cheers

And this mail will also be sent by sendmail, so the problem is the same, no?

Kind regards

fcintron 11-04-2010 08:11 PM

After six long night hours, I could forward root mail. The link that was given by quanta was very helpful:

This is the recipe:

1) I stopped sendmail.
service sendmail stop
2) I installed sendmail-cf package:
yum install sendmail-cf
2) I added these lines in sendmail.mc:

define(`SMART_HOST', `mail.example1.com')dnl
FEATURE(authinfo, `hash -o /etc/mail/authinfo')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 9999')dnl

MASQUERADE_AS(`example1.com')dnl
FEATURE(masquerade_envelope)dnl

3)I created /etc/mail/authinfo file with this line:
AuthInfo:mail.example1.com "U:root" "I:<SMTP_USER>" "P:<SMTP_PASSWORD>" "M:CRAM-MD5 DIGEST-MD5"

4) I added this line to /etc/mail/access
Try_TLS:mail.example1.com NO

5) I had to create a mail account in example1.com with the same name of the server account which was sending the mail.

6) makemap hash /etc/mail/authinfo < /etc/mail/authinfo

make -C /etc/mail

service sendmail restart

And this is all.


Thank you for your help.

sridhar21s 11-14-2012 09:59 AM

That worked!
 
Wonderful and elegant solution! Worked like a charm.

Quote:

Originally Posted by amlife (Post 4148709)
uhhh, why do you have to go through all this trouble??

simply as an alias to root with your external email address!

vim /etc/aliases & scroll to the very bottom & type
root she@example.com

when done, save your changes and do

source /etc/aliases or newaliases

now all emails destined to root will be also sent to the external email address!

That is all!

cheers



All times are GMT -5. The time now is 12:55 PM.