LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 11-03-2010, 08:59 PM   #1
fcintron
Member
 
Registered: Oct 2010
Location: México
Distribution: Centos
Posts: 71

Rep: Reputation: 4
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
 
Old 11-03-2010, 09:31 PM   #2
quanta
Member
 
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 100Reputation: 100
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')
 
1 members found this post helpful.
Old 11-03-2010, 11:46 PM   #3
amlife
Member
 
Registered: Sep 2007
Location: Canada
Distribution: RHEL, Debian, SUSE
Posts: 34

Rep: Reputation: 1
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
 
Old 11-04-2010, 05:09 AM   #4
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Linux Mint
Posts: 8,501

Rep: Reputation: 883Reputation: 883Reputation: 883Reputation: 883Reputation: 883Reputation: 883Reputation: 883
Quote:
Originally Posted by amlife View Post
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
 
Old 11-04-2010, 08:11 PM   #5
fcintron
Member
 
Registered: Oct 2010
Location: México
Distribution: Centos
Posts: 71

Original Poster
Rep: Reputation: 4
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.

Last edited by fcintron; 11-04-2010 at 08:56 PM.
 
Old 11-14-2012, 09:59 AM   #6
sridhar21s
LQ Newbie
 
Registered: Nov 2012
Posts: 1

Rep: Reputation: Disabled
Smile That worked!

Wonderful and elegant solution! Worked like a charm.

Quote:
Originally Posted by amlife View Post
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Forward certain local mail to an external mail server marciano Linux - Server 1 05-11-2009 11:08 AM
Sending root mail to an external mail account aquaboot Debian 13 01-09-2009 07:23 PM
How to configure sendmail only to send mail to external mail account Nivix Linux - Newbie 2 10-23-2008 12:46 AM
How To Forward Mail & Account Question? carlosinfl Linux - Enterprise 6 12-04-2006 04:00 PM
Postfix: Need to deliver all local mail to 1 account, then forward OneBinary Linux - Software 3 01-05-2006 04:49 PM


All times are GMT -5. The time now is 03:15 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration