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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return-Path problem - MIME::Lite - sendmail

Status
Not open for further replies.

RottPaws

Programmer
Mar 1, 2002
478
US
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 folling 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

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'm stumped.


_________
Rott Paws

...It's not a bug. It's an undocumented feature!!!
 
Switch Mime::List to use Net::SMTP and this problem will probably go away. Sendmail interactions at the OS level are obtuse to debug and manage. Net::SMTP abstracts all that really nicely and provides an interface that you can not only depend on but also debug.
 
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