发送HTML电子邮件使用PHP无法正常工作

时间:2015-07-14 09:06:01

标签: php email


我试图通过使用PHP邮件功能发送HTML电子邮件。以下是我正在使用的代码。

public function sendActivationMail($activationCode="",$receiverEmail=""){
    $subject="Registration Confirmation";
    $body="<html><body>";
    $body.="<p>Thank you for registering with us. Please Activate your account by clicking the activation link ";
    $body.="<a href=".$this->url()->fromRoute('Login/default',array('controller'=>'Index','action'=>'activation','id'=>'abc121')).">Activate</a></p>";
    $body.="</body></html>";
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n";
    $headers .= 'From: abc@gmail.com'."\r\n".'Reply-To: abc@gmail.com'."\r\n" .'X-Mailer: PHP/' . phpversion();
    $status=mail($receiverEmail,$subject,$body,$headers);
    if($status){
        return true;
    }else{
        echo "Error in sending mail";
        exit();
    }

}

但是当我查看电子邮件时,html标签会显示为文字,我不知道为什么?

2 个答案:

答案 0 :(得分:1)

您需要使用

import {ThingA,ThingB} from './things'

* - 输入CamelCase

答案 1 :(得分:0)

试试这个..

这是我的工作

为html邮件添加标头“ $this->em->persist($entity); $this->em->flush();

并发送cc,bcc“

$headers .= "Content-type: text/html\r\n";

$headers .= "Cc: [email]maa@p-i-s.cXom[/email]"; 
        $headers .= "Bcc: [email]email@maaking.cXom[/email]";