|
Ron - 2009-07-03 13:19:24
Hi Manuel,
thanks for your great classes!
I was wondering, if there is a way of setting the return path in the smtp class, especially with respect to bouncing mails.
Thanks,
Ron
Manuel Lemos - 2009-07-03 22:49:59 - In reply to message 1 from Ron
In SMTP the return path address is the sender e-mail address passed to the FROM command, which is not necessarily the same as in the From header.
Anyway, it is more recommended that you use the SMTP class in conjunction with the MIME message class, as it knows better how to compose and send messages compliant with the Internet e-mail standards.
phpclasses.org/mimemessage
ced - 2011-11-07 15:20:31 - In reply to message 2 from Manuel Lemos
Hello,
I use smtp class with sasl class and mime message class.
I have a strange header ...
If I set the debug mode, I see that :
...
...
S 235 2.7.0 Authentication successful
C MAIL FROM:<bounces@abc.com>
...
...
Return-Path: bounces@abc.com
Errors-To: =?ISO-8859-1?q?Maria=2C_Clairvoyant=2C_Universal_Medium?= <bounces@mariapsychic.com>
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="aa357aa4ff61f316723b3e87eb00769c"
Date: Mon, 07 Nov 2011 10:10:31 EST
Message-ID: <20111107101031.0578.bounces@abc.com>
...
And in the email header :
From: =?ISO-8859-1?q?Maria=2C_Clairvoyant=2C_Universal_Medium?=
<info@abc.com>
...
...
Message-ID: <20111107101031.0578.bounces@abc.com>
Return-Path: bounces@abc.com
...
...
I have 2 questions :
1) Why in the debug mode, the FROM field is equal to the Return-Path field ?
2) How can I modify the message ID to have the smtp hostname and not the Return-Path address ?
Thanks in advance for your response
Regards,
Cedric
Manuel Lemos - 2011-11-08 01:04:16 - In reply to message 3 from ced
SMTP servers do no look at the message headers, so the Return-path headers and others are irrelevant. In the SMTP protocol, the address passed by the FROM command is also to where and bounced messages will go.
Keep in mind that the SMTP FROM command is totally unrelated to the From: header, so they may point to the same address or not. This is what allows bounces to go to an address different from the sender address set in the From: header.
Setting the Return-Path: header to your bounce address is a just a convention invented by me for the MIME message class. Coincidentally other e-mail classes also adopted it.
If you want the class to not set the Message-ID header automatically, just set the class variable auto_message_id to 0.
ced - 2011-11-08 08:59:14 - In reply to message 4 from Manuel Lemos
Hi Manuel,
Thank you for your fast response.
I try the auto_message_id to 0 today.
Many thanks for your great classes !
Regards,
Cedric
ced - 2011-11-09 12:49:02 - In reply to message 4 from Manuel Lemos
Hi Manuel,
Just a question.
If I specify a return-path on the header, it will be send on the MAIL FROM.
Because your function SendMessageHeaders take it at line 713 :
if(!$this->smtp->MailFrom(count($return_path) ? Key($return_path) : Key($from)))
So I want my return path be : bounce@mydomain.com
and the MAIL FROM : webmaster@mydomain.com
Is it possible ??
thanks in advance
Manuel Lemos - 2011-11-09 19:52:54 - In reply to message 6 from ced
Sure, just try it.
ced - 2011-11-10 09:12:30 - In reply to message 7 from Manuel Lemos
I tried it but it don't work ...
When I specify a return-path address as "bounce@abc.com", the MAIL FROM smtp command take this address : MAIL FROM: bounce@abc.com
but my $from_address variable is webmaster@abc.com ...
I think it's because on your smtp_message class, in SendMessageHeaders() function, you write that :
[code]
if(!$this->smtp->MailFrom(count($return_path) ? Key($return_path) : Key($from)))
return($this->ResetConnection($this->smtp->error));
...
[/code]
So I changed this line with :
[code]
if(!$this->smtp->MailFrom(key($from)))
return($this->ResetConnection($this->smtp->error));
...
[/code]
And with this modification, MAIL FROM is good : MAIL FROM: webmaster@abc.com
But now, the return path is equal to the MAIL FROM ...
return-path: webmaster@abc.com
I think it's a bug or a configuration problem.
Here is my configuration :
[code]
$from_name=$this->senderName;
$from_address=$this->sender;
$reply_name=$from_name;
$reply_address=$this->replyTo;
$error_delivery_name=$from_name;
$error_delivery_address=$this->returnPath;
$to_name="";
$to_address=$this->to;
$subject=$this->subject;
$message=$this->message;
[/code]
And the header construct part :
[code]
$email_message->SetEncodedEmailHeader("To",$to_address,$to_name, 'UTF-8');
$email_message->SetEncodedEmailHeader("From",$from_address,$from_name, 'UTF-8');
$email_message->SetEncodedEmailHeader("Reply-To",$reply_address,$reply_name, 'UTF-8');
$email_message->SetHeader("Return-Path",$error_delivery_address);
//$email_message->SetEncodedEmailHeader("Errors-To",$error_delivery_address,$error_delivery_name);
$email_message->SetEncodedHeader("Subject",$subject);
$email_message->CreateQuotedPrintableHTMLPart($this->message,'UTF-8',$html_part);
$email_message->CreateQuotedPrintableTextPart($email_message->WrapText(VALIDATION_SUBSCRIPTION_BODY_TEXT),"",$text_part);
$alternative_parts=array($text_part,$html_part);
$email_message->CreateAlternativeMultipart($alternative_parts,$alternative_part);
$email_message->AddAlternativeMultipart($alternative_parts);
$error=$email_message->Send();
[/code]
Thank you very much for your help Manuel.
Regards,
Cedric
Manuel Lemos - 2011-11-11 06:09:47 - In reply to message 8 from ced
No, I think you are confused. The class works as intended. If you specify the Return-path header, the SMTP FROM command uses that. That command is the way to tell the SMTP server where the message should be returned in case it bounces.
The SMTP FROM command has nothing to do with the From: header. The class only uses the address in the From header if you do not specify the Return-Path: header.
In any case the From: header will always exhibit what you set it to regardless what was passed to the SMTP FROM command.
|