how to send html mails using PEAR mail

后端 未结 3 1578
独厮守ぢ
独厮守ぢ 2020-12-05 04:44

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 s

3条回答
  •  一生所求
    2020-12-05 05:39

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

    ";// Your name and email address
    $recipient = "Leigh "; // 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 message

    ';// HTML version of the email $crlf = "\r\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); ?>

    NOTE: in order for the above example to work one needs the Pear Mail Mime Package in addition the Pear Mail one. You can get the package here https://pear.php.net/package/Mail_Mime/download.

提交回复
热议问题