How can we set "Return-Path" in a mail when we use "Mail::Sendmail" module to send mail?
I want to send an email with a from address as email_id@gmail.com
to sender_to@gmail.com
from my own server. For example it should be www.example.com
I want to add the Return-path
for that email as example@example.com
. I had try many was but failed to set it properly.
The code is as follows :
#!/usr/bin/perl -w
use CGI;
use Mail::Sendmail;
%mail = (
To => $email,
From=> $user_email,
subject=> $subject,
'X-Mailer'=> "example.com Campaign Sharing Software",
);
$default_email = qq{example@example.com};
$mail{'Reply-To'} = $user_email;
$mail{'content-type'} = "text/html";
$mail{Smtp} = $GLOB{settings}{SMTPSERVER_BULK};
$mail{'Message : '} = $mail_content;
if(sendmail %mail)
{
print qq{mail sent successfully};
}
I had set $mail{'Return-Path'} = $default_email;
. But the Return-Path I found in the gmail when click on Show Original is Return-Path : from_email_id
.
Actually I want it as Return-Path : $default_email
.
From the documentation for Mail::Sendmail:
If you wish to use an envelope sender address different than the From: address, set
$mail{Sender}
in your
Most mail servers (MTAs) copy envelope sender to Return-Path:
header.