tags:

views:

653

answers:

2

Hi,

I am using PEAR mail system to send authenticated mails.I need to send HTML mails that has alinks.It was working fine before i started using PEAR mail.Now i am not able to send HTML mails.

mail body looks like this:

$body = <<<EOD

Hiya $username

You might be interested in the current 'haves' and 'wants' on example.com

Latest Haves
<a href="http://www.exmaple.com/product/have/64/Titan+Fast+Track+SunGlass"&gt;Titan Fast Track SunGlass</a>

EOD;

a tag appears as it is in the mail.Any idea how to solve this??Pls help..

A: 

Hi,

I'm not sure PEAR_Mail can send HTML E-Mail.

You should take a look at the package PEAR::Mail_Mime, that can send both plain-text and html mails.

You can see this page for a complete example.

Pascal MARTIN
+1  A: 

If you follow this example there's no reason it shouldn't work:

<?
        include('Mail.php');
        include('Mail/mime.php');

        // Constructing the email
        $sender = "Leigh <leigh@no_spam.net>";                              // Your name and email address
        $recipient = "Leigh <leigh@no_spam.net>";                           // The Recipients name and email address
        $subject = "Test Email";                                            // Subject for the email
        $text = 'This is a text message.';                                  // Text version of the email
        $html = '<html><body><p>This is a html message</p></body></html>';  // HTML version of the email
        $crlf = "\n";
        $headers = array(
                        'From'          => $sender,
                        'Return-Path'   => $sender,
                        'Subject'       => $subject
                        );

        // Creating the Mime message
        $mime = new Mail_mime($crlf);

        // Setting the body of the email
        $mime->setTXTBody($text);
        $mime->setHTMLBody($html);

        $body = $mime->get();
        $headers = $mime->headers($headers);

        // Sending the email
        $mail =& Mail::factory('mail');
        $mail->send($recipient, $headers, $body);
?>

Source:

http://www.phpmaniac.net/wiki/index.php/Pear%5FMail

karim79