Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return-Path - MIME::Lite

Status
Not open for further replies.

RottPaws

Programmer
Mar 1, 2002
478
US
I posted this to the Perl forum and all I got were suggestions to quit using MIME::Lite and sendmail . . .
--------------------------------------------------------
I've been searching for a week on the internet and read a ton of articles and forum posts, but I haven't been able to find a solution.

I have a few scripts and web pages that send automated emails when certain events occur on orders in our system. The emails appear to come from the rep who owns the order in our company.

It works fine unless there is a bad email address on the order. I would like the bounced emails to go directly to the order rep, but they don't.

My configuration is a Linux server running sendmail and I'm using MIME::Lite to send the messages from Perl scripts.

Code:
    $msg = MIME::Lite->new(
            From            => $From,
            To            => $To,
            Cc            => $CC,
            Subject        => $Sub,
            Type            => 'multipart/mixed');
    
    #Set Reply-To
    $msg->add("Return-Path", "$From");
    $msg->add("Reply-To", "$From");
            
    #Attach Body of the email
    $msg->attach(
            Type    => $BodyType,
            Data    => $Body);
    
    #Add Attachment, if any
    unless($AttFN eq ""){
        $msg->attach(
            Type    => '',
            Path    =>$AttPath,
            Filename=>$AttFN);
    } #end of attachment add

    #Send the email
    $msg->send;
I use the same code to send the email for both CGI pages and Perl scripts. The emails coming from CGI pages contain the following in the message header:

From: order.rep@company.com
Reply-To: order.rep@company.com
Return-Path: webserver@script.server.com

Perl scripts run from CRON get a return path of:
Return-Path: root@script.server.com

I have been able to send test messages that set the Return-Path as I want by using the -f switch from the command line.

Is there a sendmail setting that is overriding the MIME::Lite setting? Is there something I'm doing wrong? The Reply-To setting from MIME::Lite works.

I looked at the MIME::Lite source code and it has the following switches set for sendmail: -t -oi -oem

I'm stumped.

_________
Rott Paws

...It's not a bug. It's an undocumented feature!!!
 
I finally found the answer.

I just had to add parameters to the send method.

Code:
$msg->send('sendmail', SetSender=>1);

_________
Rott Paws

...It's not a bug. It's an undocumented feature!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top