How to set headers in PHPMAILER Class

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
eshban
Forum Contributor
Posts: 184
Joined: Mon Sep 05, 2005 1:38 am

How to set headers in PHPMAILER Class

Post by eshban »

Hello

Previously i used simple php mail() function to send emails. My main purpose is to get the receipt when the user reads the emails.

It works fine. I used this code and i perfectly got a receipt when user opens the emails via outlook.

here is my code that i have used.

Code: Select all

 
<?
$sitename = 'Contact Law';
$to_email = "abc@abc.com";
$from_email = "info@xyz.com";
 
 
$msg = "$sitename\n\n";
$msg .= "Email Recieved: $from_email\n";
$msg .= "Email Subject: $email_subject\n\n";
$msg .= "Message: $message\n\n";
$mailheaders = "Reply-To: <$from_email>\r\n";
$mailheaders .= "From: <$from_email>\r\n";
$mailheaders .= "Return-Path: <$from_email>\r\n"; //Return bounced emails to.
$mailheaders .= "X-Priority: 1\n"; //Message priority is set to HIGH
$mailheaders .= "X-MSMail-Priority: High\n"; //Message Priority for Exchange Servers
$mailheaders .= "Disposition-Notification-To: <$to_email>\r\n"; //Read receipt
$mailheaders .= "X-Mailer: PHP(".$_SERVER['REMOTE_ADDR'].")\r\n"; //IP address of who sent the mail
$mailheaders .= "Content-Type: text/HTML; charset=ISO-8859-1";
mail($to_email, $email_subject, $msg, $mailheaders);
?>
 
 
 
Now i have enhanced my code and used "PHPMAILER" class. It also works well. But i am unable to set email headers as i set in above code. I just need to set "Disposition-Notification-To" header. I have searched a lot but unable to find any method through which i can set this header in PHPMAILER CODE


Here is my phpMAILER code

Code: Select all

 
$mailcomp = & new PHPMailer();
      
    
        $mailcomp->Host     = "CC";
 
        $mailcomp->Mailer   = "sendmail";
 
        $mailcomp->Sender = $formEmailData['chemail'];
        
        $mailcomp->IsHTML(true);
        
        $mailcomp->AddAddress($formEmailData['clientemail']);
 
        $mailcomp->AddCC($formEmailData['clientemailcc']);
                
        $mailcomp->Subject = $formEmailData['subject'];
 
        $mailcomp->Body    = $formEmailData['clientmessage'];
        
        $mailcomp->AltBody = $formEmailData['clientmessage'];
 
                $mailcomp->Send();
 
 
kindly help me that how can i set headers in that phpmailer code.

thanks
Post Reply