LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 01-26-2010, 11:15 PM   #1
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Rep: Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546
Sendmail: Automatically Forwarding To Another Machine In The LAN


Howdy all,

How do I automatically forward mail to a different user on a different machine in my LAN? I have been beating my head for several hours trying to accomplish this.

I have sendmail configured as an MTA solely to receive system mail from daemons. For my personal mail I just use KMail and POP.

I want all mail on any system in my LAN to forward mail to my office system, where my normal account can receive the messages.

Although my office machine is powered on the most often, the box is not available 24/7. So any other system that can't immediately forward mail should keep that mail queued as long as necessary.

I have no problem forwarding root's mail on each local machine to a local user account on that same machine.

I have been able to forward the mails but not the way I want. The mails get forwarded to the local /var/mail/me location rather than into the remote office machine /var/mail/me.

Adding another alias in the local /etc/mail/aliases has no effect.

Creating ~/.forward in the local user's home directory also has no effect.

Both efforts always result in the mails being forwarded to the local location rather than remote.

I can send user-to-user email to and from any machine on my LAN. There are no network problems between any machine. Basic forwarding does work, just not to a remote machine at a different account.

I won't pretend to know much about mail systems, let alone sendmail. So please assume a newbie and speak softly.

Thanks again.
 
Old 01-27-2010, 12:10 AM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hello,

I'm not familiar with sendmail but I use Postfix to relay all mail on a certain server to another one, be it in the same LAN or outside of it. For example my Nagios server has Postfix configured to relay all mail (multiple destination accounts that don't even exist locally) to our GMail for Enterprises. It works without any problem. Hope that helps.

Kind regards,

Eric
 
Old 01-27-2010, 12:57 AM   #3
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Original Poster
Rep: Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546
Hmm. My mistake. I just discovered that I can send emails from my office machine to any other account on the LAN but not vice-versa. All other machines send the mail directly to the local /var/mail rather than the correct remote location. So my office machine is forwarding mail correctly but not the others. Odd and frustrating. At least the other machines are consistent. Hopefully I can find the common problem.

I diffed the /etc/mail files and all are the same on all machines. Is there something else that plays a part in this?

Quote:
I'm not familiar with sendmail but I use Postfix to relay all mail on a certain server to another one, be it in the same LAN or outside of it.
Well, okay. While I'm waiting for some sendmail genius to appear, I'll read about Postfix.

I think people who deal with mail servers are sadists.
 
Old 01-27-2010, 01:16 AM   #4
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Quote:
Originally Posted by Woodsman View Post
I think people who deal with mail servers are sadists.
More masochists in my opinion since they only inflict pain on themselves

Kind regards,

Eric
 
Old 01-27-2010, 04:46 AM   #5
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by Woodsman View Post
Hmm. My mistake. I just discovered that I can send emails from my office machine to any other account on the LAN but not vice-versa. All other machines send the mail directly to the local /var/mail rather than the correct remote location. So my office machine is forwarding mail correctly but not the others. Odd and frustrating. At least the other machines are consistent. Hopefully I can find the common problem.

I diffed the /etc/mail files and all are the same on all machines. Is there something else that plays a part in this?


Well, okay. While I'm waiting for some sendmail genius to appear, I'll read about Postfix.

I think people who deal with mail servers are sadists.
Quote:
I diffed the /etc/mail files and all are the same on all machines. Is there something else that plays a part in this?
dns maybe??
from the lan machines that do not appear to work, we need to first send an email in verbose mode to your office machine....

Code:
sendmail -X log_file -v yourofficecomputeraddress

Now, paste the contents of log_file here....
 
Old 01-27-2010, 02:23 PM   #6
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Original Poster
Rep: Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546
Solved

Well, some good news!

I inadvertently caused the problem at some point while trying to learn some basics of sendmail. I won't pretend to know even the tip of the iceberg with sendmail. A simple config file change by me was the cause of the whole exhausting evening.

I was burning the midnight oil scratching my head about this. I was certain something was configured improperly. I was reading this web page, particularly the section (scroll down a bit) titled The Default Routing Configuration. I suspected that something on my secondary systems was configured to convince sendmail to keep dumping mail locally. Yet because the configuration files all were the same across all machines, something in those files worked fine with my primary machine. Everything I tried last night resulted in the mails from the secondary machines dumping mail locally, but any mail sent from my primary office machine arrived at the targeted secondary machine.

I won't claim any genius here, but somehow I ended up at this page describing the configuration file called local-host-names.

I suspect any sendmail guru is smiling at this point. All of the configuration files were the same across all machines. In that file was some localization URLs (aliases) that worked for the primary machine. Yet when this same config file was copied to the other machines, caused sendmail to dump mails locally because the URLs in that config file said to do just that. That is, the name of the primary machine was in that file and acted like aliases. Thus any mail sent to that location was interpreted as being a local alias.

I emptied that file on all machines and restarted sendmail. Just like that I could send mails to the correct location again.

Whew!

So back to my original post. Can I forward all mails on all secondary machines to my normal user account on my primary machine?

The short answer is yes.

In the sendmail aliases config file, add an appropriate entry similar to this:

# Who gets root's mail.
root: me@mycomputer


Save the file and be sure to run the newaliases command. Unlike with the local-host-names file, changing aliases does not require restarting the sendmail daemon.

Adding to the challenge here, I have a special account on my home theater PC (HTPC). I use that account to run the system as a limited normal user. When TV recordings complete, the system send mails to that account. The mails are important because I'm still tweaking the system and the mails help me troubleshoot various errors. I wanted emails to that account sent my normal user account too.

That was what I was trying to do yesterday when All Hell Broke Loose.

The solution is straightforward.

In the user's home directory add a "hidden" text file name .forward. In that same file add the same information as in the aliases file.

Yesterday I had tried that solution too, but that local-host-names file was thwarting my attempts to forward mail.

The HTPC is not always powered on. When powered on my primary machine might not be (recording a movie at 2AM). Fortunately, sendmail queues mails and within a few days at most, the two machines are powered on concurrently and sendmail can forward the mails. The HTPC is programmed to power down after a recording when nobody is logged on, so sendmail is not going to keep trying every four hours. The queue will remain intact on the hard drive until the next time the system is powered on. At least, that is what I am hoping as I haven't tested that feature yet.

Experience often is a harsh teacher.

I hope this post helps others.

Last edited by Woodsman; 01-27-2010 at 02:28 PM.
 
1 members found this post helpful.
Old 01-27-2010, 11:45 PM   #7
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hey Woodsman,

Nice troubleshooting! And thanks for posting your findings, I'm sure they'll come in handy somewhere down the road.

Kind regards,

Eric
 
  


Reply



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
sendmail from non-AD machine to AD machine/domain DarkpawT Linux - Networking 1 04-07-2009 12:57 PM
lan connection between linux machine and windows machine arunsan842004 Linux - Laptop and Netbook 1 11-25-2008 05:44 AM
IP Forwarding with ppp for a small LAN Samoth Linux - Networking 6 01-11-2006 07:58 AM
machine has adsl ethernet modem, to make it gateway over lan do i need more lan cards b0nd Linux - Networking 2 10-04-2005 10:19 PM
Stop forwarding to certain machine bratch Linux - Networking 1 03-24-2005 06:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:15 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration