Do you know if it is posible to set a DSN communication using the Pear Mail function in PHP?
Explain: If a write this code in a telnet session:
telnet smtp.example.com 25
[...]
mail from: me@example.com
250 2.1.0 Ok
rcpt to: you@fakemail.com NOTIFY=SUCCESS,FAILURE,DELAY ORCPT=rfc822;you@fakemail.com
250 2.1.5 Ok
[]
i received a notification mail with a status code from the receiver smtp server (relayed, failed, etc.) when my smpt server sends the email. Now i want to do the same using Pear Mail, but I can't find where i have tu put this option.
This is my code:
$messageTEXT= "..." // text_message
$messageHTML="..." // html message
$headers=array();
$headers['From'] = "me@example.com";
$headers['To'] = "you@fakemail.com";
$headers['Subject'] = "Test mail";
$headers['X-Mailer']="My PHP mailer";
$headers['X-Priority']=3;
$headers['Errors-To'] = "me@example.com";
$headers['Return-Path'] = "me@example.com";
$headers['Disposition-Notification-To'] = "me@example.com";
$message = new Mail_mime();
$message->setTXTBody($messageTEXT);
$message->setHTMLBody($messageHTML);
$mimeparams=array();
$mimeparams['charset']= "UTF-8";
$mimeparams['text_encoding']="8bit";
$mimeparams['text_charset']="UTF-8";
$mimeparams['html_charset']="UTF-8";
$body = $message->get($mimeparams);
$headers = $message->headers($headers);
$smtp = Mail::factory(
'smtp',
array(
'host' => "smtp.example.com",
'port' => "25",
'auth' => true,
'username' => "myuser",
'password' => "mypass")
);
$mail=$smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
print ("Error");
return false;
}