PEAR邮件SMTP / MIME和HTML格式

时间:2012-02-21 13:39:00

标签: html email smtp pear mime

我正在尝试设置PEAR以发送已正常工作的SMTP电子邮件。

但是,我需要通过SMTP发送邮件,但我需要以HTML格式发送电子邮件 - 这是可能的。

我可以看到PEAR会运行MIME和SMTP,但我不知道是否可以将两者连接在一起?

感谢。

小时。

1 个答案:

答案 0 :(得分:0)

它可能......

这是使用它的代码..

    $to =  $customer_email;//user mail id
                        $subject = "some subject";

                        $htmlBody="<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">

<style type=\"text/css\">

SPAN {
 font-style:normal;
 font-weight:normal
}

H4 {
 text-align:left;
 margin-bottom:0px;
 margin-top:0px;
 margin-right:0px;
 direction:ltr
}
P {
 text-align:left;
 margin-bottom:12px;
 margin-top:0px;
 margin-right:11px;
 direction:ltr;
 line-height:15px
}


</style>

</head>
<body style=\"background-repeat: no-repeat\";>


<table width=\"600\" height=\"80%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">

  <tr bgcolor=\"#e3f3fd\">
  <td height=\"30%\">
  <img src=\"$logo\" alt=\"Royal Caribbean\" width=\"70px\" height=\"60px\" style=\"margin-left:50px;text-align:center;vertical-align:top;margin-bottom:14px;margin-top:25px;margin-right:0px;direction:ltr\">
  </td></tr>
  <tr ><td bgcolor=\"#e3f3fd\" width=\"600\" valign=\"top\" ><div style=\"text-align:left;margin-bottom:0px;margin-left:45px;margin-top:-20px;margin-right:0px;text-indent:0px;\">
      <h4 style=\"text-indent:0px;\"> <span style=\"font-family:&#39;sans-serif&#39;, &#39;HelveticaNeue Condensed&#39;, sans-serif; font-size:10pt; font-weight:bold; font-stretch:condensed; color:#265EAC\">Dear $customer,</span></h4>
      <p style=\"text-indent:0px;\"> <span style=\"font-family:&#39;sans-serif&#39;, &#39;HelveticaNeue LightCond&#39;, sans-serif; font-size:10pt; font-weight:normal; font-stretch:condensed; color:#265EAC\">Thanks for your blah blah blah blah blah <br/>blah blah blah blah<a href=\"$link\">clicking here</a></span></p>

      WE LOOK FORWARD TO SEE AGAIN WITH our branch </span></h4>
      <h4 style=\"text-indent:0px;\"> <span style=\"font-family:&#39;sans-serif&#39;, &#39;HelveticaNeue Condensed&#39;, sans-serif; font-size:10pt; font-weight:bold; font-stretch:condensed; color:#265EAC\">
    </div>
    </td></tr>

     <tr>
    <td><img src=\"$imagefooter\" style=\"margin-top: -30px;text-align:center;vertical-align:top;margin-bottom:14px;margin-right:0px;margin-left:0px;direction:ltr\"></td>
    </tr>
</table>


</body></html>";




                        Yii::app()->mailEx->pear(
                            $customer, // Recipient name
                            $to,
                            $subject,
                            $htmlBody
                        );