LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 06-16-2004, 10:36 AM   #1
TimothyBoggess
LQ Newbie
 
Registered: Jun 2004
Posts: 2

Rep: Reputation: 0
Question Using Sendmail to relay all mail to my Exchange Server


My goal is to be able to route all my email through my Linux server using SendMail, to my Exchange Server. Both servers are behind a firewall and I don't want the Linux box to be an open relay, just a relay for my domain. While I've looked at several SendMail config's I'm still confused (I come from a Windows environment and I'm trying to improve myself).

I have DNS in place that I can simply route email traffic to the Linux machine with a few changes in the firewall configuration so that shouldn't be a problem.

My ultimate desire for doing this is so I can load Brightmail SPAM filter on the Linux box and let it filter the garbage and then only have the real mail go through to the Exchange server.

Can anyone help me with the configuration changes I need to make? I'm running Red Hat Linux ES. TIA.

Tim
 
Old 06-17-2004, 10:26 PM   #2
TimothyBoggess
LQ Newbie
 
Registered: Jun 2004
Posts: 2

Original Poster
Rep: Reputation: 0
Here's my answer

Well since I received mostly lookers and no helpers here, I continued to delve into my own research and found this to be a workable solution.

1) First I checked my sendmail.mc file in /etc/mail to ensure it had the Feature ('mailertable', 'hash -o /etc/mail/mailertable.db') dnl line of code in it.
2) While in the sendmail.mc file commented out the line DAEMON_OPTIONS(''Port=smtp,Addr=127.0.0.1,Name=MTA')dnl
-- This change allows sendmail to receive mail from the Internet and not just the local loopback address
3)In the file mailertable I created the following line
mydomainname.com ESMTP:[192.168.100.222]
-- which is my email domain name and internal address of the server
4)I created a file called "relay-domains". In this file I put the following line
mydomainname.com
--I was told that I could use access.db for this as well, but information is cryptic and scare at best
5) To finish the process I ran the following command:
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
--this generates a new sendmail.cf file to match what I edited in the sendmail.mc file
6) And one more command as follows:
makemap hash /etc/mail/mailertable.db < /etc/mail/mailertable
--this generates a new mailertable with my domain information in it
7)Last but not least I needed to restart sendmail to pick up the information I put in the file relay-domains. To restart sendmail is used the command /sbin/service sendmail restart

That worked and mail is being transferred from the Linux server to the MS Exchange server. A note too: I had already registered weighted MX records, one with a 5 (Linux) and one with a 20 (MS Exchange) and I routed smtp mail to the Linux machine through my firewall. In the event the Linux server crashes the Exchange server will still be able to receive the mail. Thanks for listening. :-)
 
Old 06-18-2004, 12:43 AM   #3
mascdman
Member
 
Registered: Jun 2004
Location: Canada
Distribution: Ubuntu 6.06 LTS
Posts: 152

Rep: Reputation: 30
Thanks for posting the solution (I was one of the lookers ) -- I was kinda interested in how to set this up.

--mascdman
 
Old 06-22-2006, 12:48 AM   #4
mate90
LQ Newbie
 
Registered: Jun 2006
Posts: 1

Rep: Reputation: 0
trying out the same setup but his time with Postfix on suse 9.3 and Ms exchange 2003 could anyone be of help to me thxs in advance
 
Old 12-15-2006, 11:10 AM   #5
irukandji
LQ Newbie
 
Registered: Dec 2006
Posts: 2

Rep: Reputation: 0
A looker who will soon be trying this for my mail server(s) Soon to implement exchange for my domain..
Thanks!
 
Old 04-27-2007, 12:48 AM   #6
Hotchips
LQ Newbie
 
Registered: Nov 2006
Location: Brisbane, Australia
Distribution: RHEL4
Posts: 29

Rep: Reputation: 15
Hi

I am having a similar issue. I am also a newb and our company had sendmail on a linux box (RHEL4 AS) working fine as relay to an exchange server but no longer.

When sending test messages anywhere - whether local linux servers or out to the world through the relay server I get a message on the originating server in the maillog....

***For security reasons, domain/server info is masked, but present where I have masked them***

Apr 27 15:01:11 <originatingserver> sendmail[31859]: l3R51Bhw031857: SYSERR(root): <relayserver.xxx.yyy> config error: mail loops back to me (MX problem?)
Apr 27 15:01:11 <originatingserver> sendmail[31859]: l3R51Bhw031857: to=<admins@xxx.com.au>, ctladdr=<aaaa@localhost.localdomain> (2011/504), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30444, relay=<relayserver.xxx.yyy> [10.7.41.25], dsn=5.3.5, stat=Local configuration error
Apr 27 15:01:11 <originatingserver> sendmail[31859]: l3R51Bhw031857: l3R51Bhw031859: DSN: Local configuration error
Apr 27 15:01:11 <originatingserver> sendmail[30596]: l3R50AFl030596: from=ies_services, size=6070, class=0, nrcpts=1, msgid=<200704270500.l3R50AFl030596@localhost.localdomain>, relay=aaaa@localhost

I do not get any entries added to the relay log even though the originating server references this server.

Settings I have included in sendmail.mc....
ddivert(-1)dnl
dnl #
dnl # This is the sendmail macro config file for m4. If you make changes to
dnl # /etc/mail/sendmail.mc, you will need to regenerate the
dnl # /etc/mail/sendmail.cf file by confirming that the sendmail-cf package is
dnl # installed and then performing a
dnl #
dnl # make -C /etc/mail
dnl #
include(`/usr/share/sendmail-cf/m4/cf.m4')dnl
VERSIONID(`setup for Red Hat Linux')dnl
OSTYPE(`linux')dnl
dnl #
dnl # default logging level is 9, you might want to set it higher to
dnl # debug the configuration
dnl #
dnl define(`confLOG_LEVEL', `9')dnl
dnl #
dnl # Uncomment and edit the following line if your outgoing mail needs to
dnl # be sent out through an external mail server:
dnl #
define(`SMART_HOST',`exchangeservername.xxx.yyy')
LOCAL_NET_CONFIG
dnl # This rule ensures that all local mail is delivered using the
dnl # smtp transport, everything else will go via the smart host.
R$* < @ $* .$m. > $* $#smtp $@ $2.$m. $: $1 < @ $2.$m. > $3
dnl #
define(`confDEF_USER_ID',``8:12'')dnl
dnl define(`confAUTO_REBUILD')dnl
define(`confTO_CONNECT', `1m')dnl
define(`confTRY_NULL_MX_LIST',true)dnl
define(`confDONT_PROBE_INTERFACES',true)dnl
define(`PROCMAIL_MAILER_PATH',`/usr/bin/procmail')dnl
define(`ALIAS_FILE', `/etc/aliases')dnl
define(`STATUS_FILE', `/var/log/mail/statistics')dnl
define(`UUCP_MAILER_MAX', `2000000')dnl
define(`confUSERDB_SPEC', `/etc/mail/userdb.db')dnl
define(`confPRIVACY_FLAGS', `authwarnings,novrfy,noexpn,restrictqrun')dnl
define(`confAUTH_OPTIONS', `A')dnl
dnl #
dnl # The following allows relaying if the user authenticates, and disallows
dnl # plaintext authentication (PLAIN/LOGIN) on non-TLS links
dnl #
dnl define(`confAUTH_OPTIONS', `A p')dnl
dnl #
dnl # PLAIN is the preferred plaintext authentication method and used by
dnl # Mozilla Mail and Evolution, though Outlook Express and other MUAs do
dnl # use LOGIN. Other mechanisms should be used if the connection is not
dnl # guaranteed secure.
dnl # Please remember that saslauthd needs to be running for AUTH.
dnl #
dnl TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
dnl define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
dnl #
dnl # Rudimentary information on creating certificates for sendmail TLS:
dnl # cd /usr/share/ssl/certs; make sendmail.pem
dnl # Complete usage:
dnl # make -C /usr/share/ssl/certs usage
dnl #
dnl define(`confCACERT_PATH',`/usr/share/ssl/certs')
dnl define(`confCACERT',`/usr/share/ssl/certs/ca-bundle.crt')
dnl define(`confSERVER_CERT',`/usr/share/ssl/certs/sendmail.pem')
dnl define(`confSERVER_KEY',`/usr/share/ssl/certs/sendmail.pem')
dnl #
dnl # This allows sendmail to use a keyfile that is shared with OpenLDAP's
dnl # slapd, which requires the file to be readble by group ldap
dnl #
dnl define(`confDONT_BLAME_SENDMAIL',`groupreadablekeyfile')dnl
dnl #
dnl define(`confTO_QUEUEWARN', `4h')dnl
dnl define(`confTO_QUEUERETURN', `5d')dnl
dnl define(`confQUEUE_LA', `12')dnl
dnl define(`confREFUSE_LA', `18')dnl
define(`confTO_IDENT', `0')dnl
dnl FEATURE(delay_checks)dnl
FEATURE(`no_default_msa',`dnl')dnl
FEATURE(`smrsh',`/usr/sbin/smrsh')dnl
FEATURE(`mailertable',`hash -o /etc/mail/mailertable.db')dnl
FEATURE(`virtusertable',`hash -o /etc/mail/virtusertable.db')dnl
FEATURE(redirect)dnl
FEATURE(always_add_domain)dnl
FEATURE(use_cw_file)dnl
FEATURE(use_ct_file)dnl
dnl #
dnl # The following limits the number of processes sendmail can fork to accept
dnl # incoming messages or process its message queues to 12.) sendmail refuses
dnl # to accept connections once it has reached its quota of child processes.
dnl #
dnl define(`confMAX_DAEMON_CHILDREN', 12)dnl
dnl #
dnl # Limits the number of new connections per second. This caps the overhead
dnl # incurred due to forking new sendmail processes. May be useful against
dnl # DoS attacks or barrages of spam. (As mentioned below, a per-IP address
dnl # limit would be useful but is not available as an option at this writing.)
dnl #
dnl define(`confCONNECTION_RATE_THROTTLE', 3)dnl
dnl #
dnl # The -t option will retry delivery if e.g. the user runs over his quota.
dnl #
FEATURE(local_procmail,`',`procmail -t -Y -a $h -d $u')dnl
FEATURE(`access_db',`hash -T<TMPF> -o /etc/mail/access.db')dnl
FEATURE(`blacklist_recipients')dnl
EXPOSED_USER(`root')dnl
dnl #
dnl # The following causes sendmail to only listen on the IPv4 loopback address
dnl # 127.0.0.1 and not on any other network devices. Remove the loopback
dnl # address restriction to accept email from the internet or intranet.
dnl #
dnl # DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
dnl #
dnl # The following causes sendmail to additionally listen to port 587 for
dnl # mail from MUAs that authenticate. Roaming users who can't reach their
dnl # preferred sendmail daemon due to port 25 being blocked or redirected find
dnl # this useful.
dnl #
dnl DAEMON_OPTIONS(`Port=submission, Name=MSA, M=Ea')dnl
dnl #
dnl # The following causes sendmail to additionally listen to port 465, but
dnl # starting immediately in TLS mode upon connecting. Port 25 or 587 followed
dnl # by STARTTLS is preferred, but roaming clients using Outlook Express can't
dnl # do STARTTLS on ports other than 25. Mozilla Mail can ONLY use STARTTLS
dnl # and doesn't support the deprecated smtps; Evolution <1.1.1 uses smtps
dnl # when SSL is enabled-- STARTTLS support is available in version 1.1.1.
dnl #
dnl # For this to work your OpenSSL certificates must be configured.
dnl #
dnl DAEMON_OPTIONS(`Port=smtps, Name=TLSMTA, M=s')dnl
dnl #
dnl # The following causes sendmail to additionally listen on the IPv6 loopback
dnl # device. Remove the loopback address restriction listen to the network.
dnl #
dnl DAEMON_OPTIONS(`port=smtp,Addr=::1, Name=MTA-v6, Family=inet6')dnl
dnl #
dnl # enable both ipv6 and ipv4 in sendmail:
dnl #
dnl DAEMON_OPTIONS(`Name=MTA-v4, Family=inet, Name=MTA-v6, Family=inet6')
dnl #
dnl # We strongly recommend not accepting unresolvable domains if you want to
dnl # protect yourself from spam. However, the laptop and users on computers
dnl # that do not have 24x7 DNS do need this.
dnl #
FEATURE(`accept_unresolvable_domains')dnl
dnl #
dnl FEATURE(`relay_based_on_MX')dnl
dnl #
dnl # Also accept email sent to "localhost.localdomain" as local email.
dnl #
LOCAL_DOMAIN(`localhost.localdomain')dnl
dnl #
dnl # The following example makes mail from this host and any additional
dnl # specified domains appear to be sent from mydomain.com
dnl #
dnl MASQUERADE_AS(`mydomain.com')dnl
dnl #
dnl # masquerade not just the headers, but the envelope as well
dnl #
dnl FEATURE(masquerade_envelope)dnl
dnl #
dnl # masquerade not just @mydomainalias.com, but @*.mydomainalias.com as well
dnl #
dnl FEATURE(masquerade_entire_domain)dnl
dnl #
dnl MASQUERADE_DOMAIN(localhost)dnl
dnl MASQUERADE_DOMAIN(localhost.localdomain)dnl
dnl MASQUERADE_DOMAIN(mydomainalias.com)dnl
dnl MASQUERADE_DOMAIN(mydomain.lan)dnl
MAILER(smtp)dnl
MAILER(procmail)dnl



One thing I have noticed that may be an indication of the issue...
When I run
sendmail -v -d0

I get...
Version 8.13.1
Compiled with: DNSMAP HESIOD HES_GETMAILHOST LDAPMAP LOG MAP_REGEX
MATCHGECOS MILTER MIME7TO8 MIME8TO7 NAMED_BIND NETINET NETINET6
NETUNIX NEWDB NIS PIPELINING SASLv2 SCANF STARTTLS TCPWRAPPERS
USERDB USE_LDAP_INIT

============ SYSTEM IDENTITY (after readcf) ============
(short domain name) $w = localhost
(canonical domain name) $j = localhost.localdomain
(subdomain name) $m = localdomain
(node name) $k = relayserverdomainname.xxx.yyy
========================================================

Recipient names must be specified

I think I should be getting domain names resolved for these variables. I don't know if my relay server knows it's own name. I have updated alias file though.

Can anyone assist with this? I have spen a day and a half trying to sort it without any luck.

Cheers.
 
Old 04-30-2007, 06:13 PM   #7
Damiand
LQ Newbie
 
Registered: Jun 2004
Posts: 8

Rep: Reputation: 0
I am also having a problem where I need to change the localhost.localdomain name to be the correct name of the send mail server. How do I go about doing this?
 
Old 05-01-2007, 03:32 AM   #8
Hotchips
LQ Newbie
 
Registered: Nov 2006
Location: Brisbane, Australia
Distribution: RHEL4
Posts: 29

Rep: Reputation: 15
Lightbulb

I solved issue by editing /etc/hosts file on relay server so it now knows what it is instead of only understanding itself as "localhost.localdomain"

I added the ip address and fqdn and alias to /etc/hosts so the file now looks like....

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
10.x.y.z linux.qld.aus linux

...added this line in and restarted server to clear bind cache, and hey presto!!!

The test is to ping the server.

If I ping linux.qld.hpa from linux.qld.aus it was returning
Response from localhost.localdomain....

Now it responds with the proper server name.

See how you go.

Cheers,

Last edited by Hotchips; 05-18-2007 at 05:07 AM.
 
  


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
Using sendmail to relay mail to ISP mail server Swift&Smart Linux - Software 26 11-09-2008 03:00 PM
Mail Relay Server by using Sendmail raymond117 Linux - Security 2 05-11-2005 10:25 AM
Sending mail from linux using MS Exchange relay host a2k2 Linux - General 0 08-16-2004 01:55 PM
relay mail to sendmail relay server??? lemay_jeff Linux - Newbie 0 07-06-2004 04:54 PM
mail relay problem with sendmail ilovebytes Linux - Networking 5 11-16-2003 07:56 AM


All times are GMT -5. The time now is 03:48 PM.

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