LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 06-05-2006, 04:50 AM   #1
Yalla-One
Member
 
Registered: Oct 2004
Location: Norway
Distribution: Slackware, CentOS
Posts: 641

Rep: Reputation: 36
Configuring sendmail for mail forwarding to server


It's time to become a bit more advanced

I've got a home network of 4-5 laptops (asterix, idefix, etc) who all connect to a central server (majestix) for local services etc.

What I need is to configure all the clients to have sendmail use the majestix-server as gateway. I assume this is very similar to most setups at campuses and companies, so I guess there's a default/simple way to configure asterix and idefix's sendmail.cf to just forward everything to majestix..

Once I've got that figured out I'll post back and ask how to get majestix to talk to the great-big-old internet, but one baby-step at the time

Thanks in advance!
 
Old 06-05-2006, 05:28 AM   #2
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559

Rep: Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106
You should set the "Smart Host" in /etc/mail/sendmail.cf to majestix:
Code:
# "Smart" relay host (may be null)
DSmajestics
And then restart sendmail:
Code:
/etc/rc.d/rc.sendmail restart
.
If you use m4 to generate a sendmail.cf out of a sendmail.mc file, you should be adding
Code:
define(`SMART_HOST',`majestix')
to the .mc file and then rebuild the sendmail.cf.
Now, sendmail will forward all mail to the Smart Host, and will assume that host is smart enough to know how to handle all mail :-)

Eric
 
Old 06-05-2006, 06:10 AM   #3
Yalla-One
Member
 
Registered: Oct 2004
Location: Norway
Distribution: Slackware, CentOS
Posts: 641

Original Poster
Rep: Reputation: 36
Thanks much for once again coming to the rescue - my home network is getting close to perfect now thanks to your (and others) help

Quote:
Originally Posted by Alien Bob
Now, sendmail will forward all mail to the Smart Host, and will assume that host is smart enough to know how to handle all mail :-)
I guess it's more a question of whether or not the operator is smart enough to configure this correctly..

..which I'm not - so on to the next question. Now that I am taking the vanilla sendmail-slackware files and modifying them as you recommended and running m4 on all the clients/hosts, I need to prepare the home server to receive all of this. I don't want the server to be open to everyone and used as a SPAM relay, so all I want it to do is accept the incoming stuff from the client hosts I just configured, and then forward it to my VPS-hosted server in the US.

Is all I need to do on majestix to configure the same SMART_HOST as vps.mycompany.com and voila - it's up and running, or do I need to do some more intelligent stuff on majestix to gather and allow emails from all the asterix and idefix'es and pass it on?

-Y1
 
Old 06-05-2006, 07:35 AM   #4
Yalla-One
Member
 
Registered: Oct 2004
Location: Norway
Distribution: Slackware, CentOS
Posts: 641

Original Poster
Rep: Reputation: 36
For some reason, /etc/mail/sendmail.cf doesn't contain the DSmajestix field, even though I have the (supposedly) correct field in sendmail-slackware.mc.

Here's what I've done:

1. Modify defailt /usr/share/sendmail/cf/cf/sendmail-slackware.mc with :
Code:
dnl define(`SMART_HOST',`majestix')
(instead of mailserver.example.com
2. Run
Code:
m4 /usr/share/sendmail/cf/cf/sendmail-slackware.mc > /etc/mail/sendmail.cf
3. search for DS in /etc/mail/sendmail.cf:
Code:
# "Smart" relay host (may be null)
DS
What am I doing wrong here?
 
Old 06-05-2006, 07:37 AM   #5
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559

Rep: Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106
Quote:
Originally Posted by Yalla-One
all I want it to do is accept the incoming stuff from the client hosts I just configured, and then forward it to my VPS-hosted server in the US.

Is all I need to do on majestix to configure the same SMART_HOST as vps.mycompany.com and voila - it's up and running, or do I need to do some more intelligent stuff on majestix to gather and allow emails from all the asterix and idefix'es and pass it on?

-Y1
...yes. There are some refinements you probably have to make to have sendmail accept and relay your internal machines' emails, like in
Code:
/etc/mail/local-host-names
I list all the hostnames my server will be addressed as - mine looks (almost) like
Code:
# names of hosts for which we receive email
localhost
my.net
gate.my.net
sox.homeip.net
and perhaps you'll have to populate
Code:
 /etc/mail/relay-domains
as well if your sendmail refuses to relay the mail coming from your otehr PC's. Mine (roughly) says
Code:
my.net
Eric
 
1 members found this post helpful.
Old 06-05-2006, 08:01 AM   #6
Yalla-One
Member
 
Registered: Oct 2004
Location: Norway
Distribution: Slackware, CentOS
Posts: 641

Original Poster
Rep: Reputation: 36
Thanksmuch - again. It's all so easy once it's been done for the first time

Seems like /etc/mail/sendmail.cf refuses to get the SMART_HOST field (DS) - can I just edit that manually, or is it left out for a reason that I should fix somewhere?

-Y1
 
Old 06-05-2006, 08:53 AM   #7
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559

Rep: Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106
Quote:
dnl define(`SMART_HOST',`majestix')
The "dnl" indicates the start of a comment line... whatever follows that will not show up in your sendmail.cf once you've generated it using m4. Look at my original example, it did not contain "dnl " (dnl stands for "delete until new line")

Eric
 
Old 06-05-2006, 09:02 AM   #8
Yalla-One
Member
 
Registered: Oct 2004
Location: Norway
Distribution: Slackware, CentOS
Posts: 641

Original Poster
Rep: Reputation: 36
Referring back to the "intelligent" comment in the initial post and rest my case

Apparently the devil is in the detail - missed that one completely. Thanks a bunch again.

-Y1
 
Old 06-05-2006, 09:36 AM   #9
Yalla-One
Member
 
Registered: Oct 2004
Location: Norway
Distribution: Slackware, CentOS
Posts: 641

Original Poster
Rep: Reputation: 36
Still not quite there - this seems to be complicated stuff.

I've got all the clients to happily forward the email to the server (majestix), and likewise, the server happily accepts these connections and deals with it on behalf of all the machines in the network.
However, when the server(majestix) on yallanet.com tries to connect to the VPS server on mailserver.example.com, it all goes haywire. I have added the internal mailservers (majestix) static, public IP address to the VPS servers /etc/relayhosts in order for it to accept relay from majestix.

The result bounces back like this:
Code:
From MAILER-DAEMON@majestix.yallanet.com  Mon Jun  5 16:17:58 2006
Return-Path: <MAILER-DAEMON@majestix.yallanet.com>
Date: Mon, 5 Jun 2006 16:17:58 +0200
From: Mail Delivery Subsystem <MAILER-DAEMON@majestix.yallanet.com>
To: <user@asterix.yallanet.com>
Content-Type: multipart/report; report-type=delivery-status;
    boundary="k55EHwHZ009456.1149517078/majestix.yallanet.com"
Subject: Returned mail: see transcript for details
Auto-Submitted: auto-generated (failure)
Status: RO

Part 1:

The original message was received at Mon, 5 Jun 2006 16:17:56 +0200
from asterix.yallanet.com [192.168.1.105]

   ----- The following addresses had permanent fatal errors -----
<user@yallanet.com>
    (reason: 550-Verification failed for <user@asterix.yallanet.com>)

   ----- Transcript of session follows -----
... while talking to mailserver.example.com.:
>>> DATA
<<< 550-Verification failed for <user@asterix.yallanet.com>
<<< 550-unrouteable mail domain "asterix.yallanet.com"
<<< 550 Sender verify failed
550 5.1.1 <user@yallanet.com>... User unknown
<<< 503 valid RCPT command must precede DATA

Part 2:
Content-Type: message/delivery-status

Part 3:
Content-Type: message/rfc822

From user@asterix.yallanet.com Mon Jun  5 16:17:56 2006
Return-Path: <user@asterix.yallanet.com>
From: Yalla-One <user@asterix.yallanet.com>
Date: Mon, 05 Jun 2006 16:17:57 +0200
To: user@yallanet.com
Subject: Second test email
User-Agent: nail 11.25 7/29/05
Content-Type: text/plain; charset=us-ascii

This is an email sent from client computer ASTERIX through server MAJESTIX to servint host mailserver.
example.com.
I hope it works.
lines 20-48/48 (END)
On the hosted VPS server, exim's reject-log corresponds:
Code:
2006-06-05 18:17:59 H=(majestix.yallanet.com) [1x3.2x3.1x.x1x] sender verify fail for <user@asterix.yallanet.com>: unrouteable mail domain "asterix.yallanet.com"
2006-06-05 18:17:59 H=(majestix.yallanet.com) [1x3.2x3.1x.x1x] F=<user@asterix.yallanet.com> rejected
 RCPT <user@yallanet.com>: Sender verify failed
Thus I am assuming that at least one of the errors is that I need to get sendmail on majestix to rewrite the header to skip the hostname asterix ?
This is a normal cPanel/WHM setup if that helps...

I guess this is beginning to reach a complexity-level beyond what it is reasonable to expect my fellow Slackware-LQ users to be able to help with, but on the off-chance that I am a small configuration tweak away from reaching my goal, I post my failure here as a sort of a last resort

Thanks again for much appreciated help getting me this far

-Y1

Last edited by Yalla-One; 06-05-2006 at 09:42 AM.
 
Old 06-05-2006, 09:59 AM   #10
Yalla-One
Member
 
Registered: Oct 2004
Location: Norway
Distribution: Slackware, CentOS
Posts: 641

Original Poster
Rep: Reputation: 36
Solved!

Nothing like a full day off with nothing to do to learn great new things. The problem is finally solved, thanks to Eric and Google.

By adding
Code:
MASQUERADE_AS(`yallanet.com')
MASQUERADE_DOMAIN(`yallanet.com')
FEATURE(`masquerade_entire_domain')
FEATURE(`masquerade_envelope')
to the sendmail-slackware.mc file, I got my sendmail to rewrite the header before communicating with the VPS server, and now everything is perfectly accepted.

What a motivating day

-Y1
 
Old 06-05-2006, 10:05 AM   #11
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559

Rep: Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106
I guess you should masquerade the internal host(s) your emails were sent from.
You can add these lines to your .mc file on the smarthost (majestix) and rebuild the sendmail.cf with it:
Code:
MASQUERADE_AS(yallanet.com)dnl
FEATURE(`allmasquerade')dnl
FEATURE(`masquerade_envelope')dnl
Then, all email will appear to come from "user@yallanet.com" no matter what host it was originating from. The domain yallanet.com must have an associated MX record in DNS so that return email can actually be delivered. Most ISP's allow incoming traffic at the smtp port 25 so in that case, your own server can handle the incoming emails (and then it will become time to think about your own internal IMAP server :-).
If not, you must rewrite the "MASQUERADE_AS(yallanet.com)dnl" into "MASQUERADE_AS(yourisp.com)dnl" so that return emails will be sent to your ISP where you can fetch them like you probably already are.
Hope this still makes any sense to you (and others reading).

Eric
 
Old 06-05-2006, 10:27 AM   #12
Yalla-One
Member
 
Registered: Oct 2004
Location: Norway
Distribution: Slackware, CentOS
Posts: 641

Original Poster
Rep: Reputation: 36
Hi,

All return emails are going as they should to the servint VPS server, which is monitored and probably more stable than my home server sitting in the storage cabinet beneath my wife's sowing machine So while I do have a static IP at home, I haven't opened port 25 in the firewall, as the MX-record for our domain externally points to servint VPS and internally points to majestix.

However, only one minor detail remains. When I at the prompt of my machine (asterix) type mailx user, mail is still delivered locally on asterix' /var/spool/mail/user, but if I type mailx user@yallanet.com or my_friend@his_domain.org it works as planned.

I have the line FEATURE(`always_add_domain')dnl in the config-file, but that doesn't seem to cut it.
Is there a command that forces all email delivery, also local, to be sent to majestix for further processing at the servint box?

-Y1
 
Old 06-05-2006, 11:52 AM   #13
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559

Rep: Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106
Well, local delivery if a user account exists, is just what Sendmail shouldbe doing of course. What you see if completely normal and desired behaviour. Remember, this is Linux, where each computer might as as well be called a server, with it's multiple accounts. The mail address without any domain appended, is per definition a local account.

Your only way out would be to start using full email addresses including a "@yallanet.com" domain part, so that mail for it will be directed to the smarthost, or define an alias for the local account "user" that points to "user@yallanet.com" - or create a ~/.forward file that basically does the same - forward all incoming local mail to the smarthost.

Eric
 
Old 06-05-2006, 12:03 PM   #14
Yalla-One
Member
 
Registered: Oct 2004
Location: Norway
Distribution: Slackware, CentOS
Posts: 641

Original Poster
Rep: Reputation: 36
I know, but in a multi-host environment I don't want computer novices to have different emails depending on which computer they happen to be working from, so I added LOCAL_RELAY pointing to majestix which solved most of it.

Another thing to be aware of (which I haven't been able to solve yet, but has contributed significantly to the confusion) is that WHM/cPanel overwrites /etc/relayhosts each time a user POPs their email with POP3, which means that I need to find an alternate way to get exim to permanently read my accepted relay host IP address as /etc/relayhosts is clearly used for something else...

Another thing that would be neat would be if emails from root (which I now know is a protected user and thus not rewritten with the masquerading) could be totally rewritten as to appear from admin@example.com instead of root@host.example.com ... But that's for the next short holiday

-Y1
 
Old 10-06-2006, 10:35 AM   #15
fakie_flip
Senior Member
 
Registered: Feb 2005
Location: San Antonio, Texas
Distribution: Gentoo Hardened using OpenRC not Systemd
Posts: 1,495

Rep: Reputation: 85
Quote:
Originally Posted by Yalla-One
For some reason, /etc/mail/sendmail.cf doesn't contain the DSmajestix field, even though I have the (supposedly) correct field in sendmail-slackware.mc.

Here's what I've done:

1. Modify defailt /usr/share/sendmail/cf/cf/sendmail-slackware.mc with :
Code:
dnl define(`SMART_HOST',`majestix')
(instead of mailserver.example.com
2. Run
Code:
m4 /usr/share/sendmail/cf/cf/sendmail-slackware.mc > /etc/mail/sendmail.cf
3. search for DS in /etc/mail/sendmail.cf:
Code:
# "Smart" relay host (may be null)
DS
What am I doing wrong here?
Shouldn't

Code:
dnl define(`SMART_HOST',`majestix')
be smtp.majestix.com or something similar?
 
  


Reply

Tags
sendmail



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
Mail forwarding using Sendmail yunus.raza Linux - Software 4 04-19-2008 01:44 AM
Mail Forwarding in postfix/maildrop/redhat (like yahoo mail forwarding) topcat Linux - Software 1 08-31-2007 12:10 PM
Sendmail second server/mail forwarding? WorldBuilder Linux - Networking 4 03-11-2004 06:10 PM
configuring sendmail to use external mail servers tt826 Linux - Networking 42 12-05-2003 11:13 AM
mail forwarding problem with sendmail JelloMaster Linux - Software 18 08-14-2003 09:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:20 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