lablett has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to send a mail message to a Lotus SMTP mail server and the code is below. My problem is that the Mail gateway is stopping the message becuase the from account is not valid is thinks it is from postmaster@hhamiwovts although I do set the from account. I have set verbose debuggin on and got the following output. Can I fix this or do I have use a different method ?
output Net::SMTP=GLOB(0xbbc028)<<< 220 hsbcib.com MAILsweeper ESMTP Receiver + Version 4 .2.5.0 Ready Net::SMTP=GLOB(0xbbc028)>>> EHLO localhost.interwoven.com Net::SMTP=GLOB(0xbbc028)<<< 250-hsbcib.com Net::SMTP=GLOB(0xbbc028)<<< 250-SIZE 0 Net::SMTP=GLOB(0xbbc028)<<< 250-ETRN Net::SMTP=GLOB(0xbbc028)<<< 250-ENHANCEDSTATUSCODES Net::SMTP=GLOB(0xbbc028)<<< 250-DSN Net::SMTP=GLOB(0xbbc028)<<< 250-VRFY Net::SMTP=GLOB(0xbbc028)<<< 250-AUTH Net::SMTP=GLOB(0xbbc028)<<< 250 8BITMIME Net::SMTP=GLOB(0xbbc028)>>> MAIL FROM:<postmaster@HHAMIWOVTS> Net::SMTP=GLOB(0xbbc028)<<< 250 2.0.0 postmaster@hhamiwovts OK Net::SMTP=GLOB(0xbbc028)>>> RCPT TO:<leeablett@hotmail.com> Net::SMTP=GLOB(0xbbc028)<<< 250 2.0.0 leeablett@hotmail.com OK Net::SMTP=GLOB(0xbbc028)>>> DATA Net::SMTP=GLOB(0xbbc028)<<< 354 Ready for data Net::SMTP=GLOB(0xbbc028)>>> Subject: HSBC Asset Management (Europe) In +ternet Sit e Update Net::SMTP=GLOB(0xbbc028)>>> SMTPOriginator: Andrew.Webster@hsbcam.com Net::SMTP=GLOB(0xbbc028)>>> To: leeablett@hotmail.com Net::SMTP=GLOB(0xbbc028)>>> From: Andrew.Webster@hsbcam.com Net::SMTP=GLOB(0xbbc028)>>> MAIL FROM: Andrew.Webster@hsbcam.com Net::SMTP=GLOB(0xbbc028)>>> Content-Type: text/plain; charset=UTF-8 Net::SMTP=GLOB(0xbbc028)>>> Return-Path: Andrew.Webster@hsbcam.com Net::SMTP=GLOB(0xbbc028)>>> Date: Thu 21 Nov 2002 16:36:50 GMT Net::SMTP=GLOB(0xbbc028)>>> X-Mailer: Mail::Mailer[v1.18] Net::SMTP[v2 +.15] sub sendMail{ my ($emailAddress,$title,$firstName,$surname,@mailSets) = @ +_; #===================================================================== # Construct date header #===================================================================== my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time +); $year += 1900; $mon = (qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec))[ $mon ] +; $wday = (qw(Sun Mon Tue Wed Thu Fri Sat))[ $wday ]; my $date = "$wday $mday $mon $year $hour:$min:$sec GMT"; debug("Mail set : @mailSets"); my($mailer) = new Mail::Mailer('smtp', Server => $mailServer); my(%headers) = ( 'SMTPOriginator' => $siteMessageFrom, 'To' => $emailAddress, "Return-Path" => $siteMessageFrom, 'From' => $siteMessageFrom, 'MAIL FROM' => $siteMessageFrom, 'Subject' => $siteMessageSubject, 'Date' => $date, 'Content-Type' => 'text/plain; charset=UTF-8', ); #=#================DEBUGGING foreach my $k (sort(keys(%headers))){ if (ref($headers{$k}) eq "ARRAY"){ foreach my $e (@{$headers{$k}}){ #debug("$k ==> $e"); } } else { #debug("$k => $headers{$k}"); }} my $message = $siteMailTemplate; my $messageSet; foreach my $set (@mailSets){ $messageSet .= "$setName{$set}\t\t$setFullURL{$set} \n"; } $message =~ s/\$\$sections/$messageSet/g; $message =~ s/\$\$title/$title/g; $message =~ s/\$\$surname/$surname/g; $message =~ s/\$\$firstName/$firstName/g; #debug($message); $mailer->open(\%headers); print $mailer $message; #$mailer->close; }

Replies are listed 'Best First'.
Re: Lotus SMTP
by iburrell (Chaplain) on Nov 21, 2002 at 16:58 UTC
    From looking at Mail::Mailer, the way that you are setting the "MAIL FROM" address doesn't work. Mail::Mailer constructs the address and doesn't look at the From: header or the 'MAIL FROM' header. It does look at the MAILADDRESS environment variable. BTW, you should set the Return-Path header. That is set by the receiving MTA.

    You could set the environment variable before sending the message.

    $ENV{MAILADDRESS} = $$siteMessageFrom; $mailer->open(\%headers);
Re: Lotus SMTP
by grinder (Bishop) on Nov 21, 2002 at 21:09 UTC

    Mail::Mailer is a pretty crufty old piece of code. I would recommend using Mail::Sendmail (which is pure perl), or even Net::SMTP (which is a little more low-level, but fine if you're playing around inside your localnet). I have used both of these modules to talk to Lotus MTAs, and they work just fine, and I can diddle the headers however I want (with reason).

    For instance, I often set the From: line to be the name of the application that is generating the message, and set the Reply-To: to the person who is capable of taking care of what issues may be raised by the contents.


    print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'