[ale] sendmail configuration
Chris Fowler
cfowler at outpostsentinel.com
Wed Jan 12 17:54:14 EST 2011
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";
}
More information about the Ale
mailing list