[ale] sendmail configuration

Lightner, Jeff jlightner at water.com
Thu Jan 13 10:05:35 EST 2011


Since you're doing what I thought originally then setting the smart host
with the details I put in my first reply should be sufficient from the
Sendmail side.   As noted you also have to have someone setup the
Exchange side to allow the Sendmail host to relay through it.

Also I have had to setup relay on RHEL Sendmail hosts as by default they
only allow localhost (127.0.0.1) to "relay" so anything that came out
one of the other interfaces (e.g. eth0) needs to also be allowed to
"relay" within Sendmail itself.

Notes I wrote myself some time ago:
I'd found that on one our RHEL hosts I could access sendmail on
"localhost" but not on the live IP for the host (or with FQDNs)   This
seemed likely to be a Sendmail configuration issue rather than firewall
but it was important to verify this to validate our other  assumptions
about firewall.

First I did a test to the RHEL host from the RHEL host with the firewall
turned off and got connection refused.  (This verified issue was not in
the firewall.)

I found the issue was that the DAEMON_OPTIONS in sendmail.mc was
restricting to "127.0.0.1" for  localhost with the following entry:
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl

On doing some reading I found you can't have multiple addresses on same
line
so must add the new address on a new line.  Accordingly the above entry
was
left intact and a new entry was added with the IP for eth0:
DAEMON_OPTIONS(`Port=smtp,Addr=192.168.1.1, Name=MTA')dnl

Once that modification was made to sendmail.mc the following command was
run:
make -C /etc/mail

That recreated the sendmail.cf from the sendmail.mc.   (As noted
previously you have to have both the Sendmail and Sendmail.cf packages
installed for this work. - The sendmail package installs the Sendmail.cf
file but NOT the Sendmail.cf package)

Afterwards I was able to telnet to port 25 using the host's name and
its FQDNs (e.g. host1, host1.example.com - of course this assumes you
have the correct entries in /etc/hosts for those.)
I also verified that telnet to port 25 on this host from outside it does
NOT succeed which is the correct behavior.

NOTE:  I also added the host name aliases to /etc/mail/access:
localhost.localdomain   RELAY
localhost               RELAY
127.0.0.1               RELAY
host1      			RELAY
host1.example.com       RELAY
192.168.1.1		      RELAY

On running the make above it created access.db from the access file.  I
note
this because I did this before the DAEMON_OPTIONS and it didn't help so
I
don't think it matters but the local names should be in access (and
access.db) anyway.

-----Original Message-----
From: ale-bounces at ale.org [mailto:ale-bounces at ale.org] On Behalf Of
Chris Fowler
Sent: Wednesday, January 12, 2011 5:54 PM
To: Atlanta Linux Enthusiasts
Subject: Re: [ale] sendmail configuration

On Wed, 2011-01-12 at 17:56 -0500, Geoffrey Myers wrote:
> Lightner, Jeff wrote:
> > ?
> > 
> > Maybe I misunderstood the original question.   The original question
I
> > thought was about relaying Linux generated Sendmail to Exchange.
Such
> > relay is typically making an smtp connection.  When you use the
> > "sendmail" or "mailx" command line (as I thought you were doing) to
send
> > mail from the Linux host to other recipients via the Exchange host
then
> > that's all you need.   The Exchange host itself would then decide
what
> > it needs to do to get the email to the correct mail box (e.g. to an
> > internal Exchange account or to external accounts which it would in
turn
> > establish an SMTP connection to assuming it has been configured to
send
> > email out - that is what we do here.)
> 
> That's exactly what we need to do.  Whether it's via the command line
or 
> perl.  We want something like this to work:
> 
> date|mail foo at bar.com

# Probably Syntax errors.  I'm writing this from memory.  This is the
basic.

use Net::SMTP::SSL;
use Getopt::Std;
use vars qw/$opt_s $opt_d/;
use strict;
use warnings;

$opt_s = "Mail from Server";
$opt_d = 0;

getopts("ds:");

my $from = 'server at server.com';
my $to = ARGV[0];

die "$0 [-d] [-s subject] <to address>\n" unless $to;

eval {
  my $smtp = Net::SMTP::SSL->new('aaa.bbb.ccc.ddd', Port => 465, Debug
=> $opt_d) or die "Connection Failed: $!";

  # Only is auth required!
  $smtp->auth($user, $pass) or die $smtp->message();

  $smtp->mail($from) or die $smtp->message();
  $smtp->to($to) or die $smtp->message();
  $smtp->data();
  $smtp->datasend("To: $to\n");
  $smtp->datasend("From: $from\n");
  $smtp->datasend("Subject: $opt_s\n\n");
  
  while(<STDIN>) {
    $smtp->datasend($_);
  }
  
  $smtp->datasend();
  $smtp->quit();
};
if($@) {
  print "ERROR: $@\n";
}




_______________________________________________
Ale mailing list
Ale at ale.org
http://mail.ale.org/mailman/listinfo/ale
See JOBS, ANNOUNCE and SCHOOLS lists at
http://mail.ale.org/mailman/listinfo
 
Proud partner. Susan G. Komen for the Cure.
 
Please consider our environment before printing this e-mail or attachments.
----------------------------------
CONFIDENTIALITY NOTICE: This e-mail may contain privileged or confidential information and is for the sole use of the intended recipient(s). If you are not the intended recipient, any disclosure, copying, distribution, or use of the contents of this information is prohibited and may be unlawful. If you have received this electronic transmission in error, please reply immediately to the sender that you have received the message in error, and delete it. Thank you.
----------------------------------



More information about the Ale mailing list