在php邮件中发送HTML链接

时间:2017-11-03 12:58:05

标签: php phpmailer

我正在尝试使用php发送邮件中的html链接。但是我在邮件中获得了html的全文。以下是我尝试过的代码。但它没有用。任何帮助表示赞赏。

const selectorCorB = createSelector(
  selectorB,
  selectorC,
  selectorStateX,
  (b, c, x) => x? b: c
) 

mySelector = createSelector(
    [selectorA, selectorCorB], // will be A AND B OR C depending on x
    (foo, cOrb) => {
        // ...
    }
);

以下是我使用标记

收到的邮件

HTTP://www.google.com'>点击这里

2 个答案:

答案 0 :(得分:0)

使用模板粘贴工作代码并运行

    <?

 $to = $send_to;
         $subject = $mail_subject;
         $message .= '<div style="margin:0;font-weight:lighter;background:#f0f4f7;">
    <table class="m_6501530908114331344layout" style="font-family:Helvetica,Arial,sans-serif;background:#f0f4f7;width:100%">
      <tbody><tr>
        <td>
          <table cellspacing="0" class="m_6501530908114331344page-container" width="505" align="middle" style="font-family:Helvetica,Arial,sans-serif;border-spacing:0;background-color:#fff;max-width:505px!important;display:block!important;margin:25px auto!important;clear:both!important">
            <tbody><tr class="m_6501530908114331344header" style="background-color:rgba(218, 23, 23, 0.03);">
              <td class="m_6501530908114331344row" style="border-left:1px solid #e7e7e7;border-right:1px solid #e7e7e7;border:none;padding:20px 35px">
          <img alt="lasaioffice" height="80" width="300" src="https://www.google.co.in/images/branding/googlelogo/2x/googlelogo_color_120x44dp.png" class="CToWUd">
              </td>
            </tr>
            <tr class="m_6501530908114331344subject" style="background-color:#fff">
              <td class="m_6501530908114331344primary-message" style="padding:20px 35px 0">
                  <p style="margin:20px 0;line-height:1.45">Hi google </p>



<h2 class="m_6501530908114331344centered" style="font-size:24px;font-weight:bold;margin:0;margin-bottom:30px;display:block;text-align:center;margin-bottom:0;color:#eb2028;">
  Just one more click
</h2>


<table class="m_6501530908114331344email-btn" style="font-family:Helvetica,Arial,sans-serif;background:#eb2028;padding:10px">
  <tbody><tr>
    <td>
 <a href="http://google.com" style="text-decoration:none;color:#088df6;color:#fff;" target="_blank">Activate Account</a>
    </td>
  </tr>
</tbody>
</table>




                  <p style="margin:20px 0;line-height:1.45">
                    <strong style="font-weight:bold">
                      Kind Regards, <br>
                      The google Team
                    </strong>
                  </p>
              </td>
            </tr>
            <tr class="m_6501530908114331344footer" style="color:#7f8da0">
              <td class="m_6501530908114331344footer-tagline" style="padding:0 35px">
                <hr class="m_6501530908114331344footer-line-break" style="margin-bottom:35px;border:0;border-bottom:1px solid #d3dbe3">
                <p class="m_6501530908114331344small" style="font-size:12px">
                  <strong style="font-weight:bold">
                    <a style="color:#eb2028;" href="http://google.com">google</a> -
                    The leading marketplace selling google.
                  </strong>
                </p>
                  <p class="m_6501530908114331344small" style="font-size:12px">
                    This account notification was sent to you because you are a google user.
                    Should you have any questions, you are welcome to <a href="mailto:#" style="text-decoration:none;color:#088df6;color:#7f8da0;text-decoration:underline" target="_blank">email us</a>.
                  </p>
              </td>
            </tr>
            <tr class="m_6501530908114331344footer" style="color:#7f8da0">
              <td class="m_6501530908114331344footer-links" style="padding:20px 35px 45px">
                <p class="m_6501530908114331344small" style="font-size:12px">
                  Copyright © 2017 | google Pty Ltd. All rights reserved.
                </p>
              </td>
            </tr>
          </tbody></table>
        </td>
      </tr>
    </tbody></table>

<img src="" alt="" width="1" height="1" border="0" style="height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important" class="CToWUd"><div class="yj6qo"></div><div class="adL">
</div></div>';

         $header = "From:abc@gmail.com \r\n";
         $header .= "MIME-Version: 1.0\r\n";
         $header .= "Content-type: text/html\r\n";

         $retval = mail ($to,$subject,$message,$header);

         if( $retval == true ) {
            echo "Message sent successfully...";
         }else {
            echo "Message could not be sent...";
         }


?>

答案 1 :(得分:0)

我已经检查了您的代码..

好像你犯了一个简单的错误.. 您没有连接代码..您将在第3行重新分配标题

您的代码

$emailid = $_POST['email'];
$phoneno = $_POST['phoneno'];
 $to = "demoemail@gmail.com"; // this is your Email address
$from = $emailid;  // this is the sender's Email address
$subject = "Intrested in scheduling appointment.";
$message = "<a href='http://www.google.com'>Click Here</a>"; 
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers = "From:" . $from;
$retval = mail($to,$subject,$message,$headers);

更新了标题代码:

    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= "From:" . $from;

更新标题,然后重试!

谢谢!祝你有愉快的一天!