【问题标题】:How to add button in PHP Mail function?如何在 PHP 邮件功能中添加按钮?
【发布时间】:2018-04-30 19:59:34
【问题描述】:

我正在尝试在带有 href 的锚标记中插入一个按钮。我希望用户看到一个按钮而不是一个链接

<a href='http://example.com/PhpProject3/reset_passwd.php?key="<?= $email; ?>"&userid="<?= $userid; ?>"' style=' background-color: #4CAF50;border: none;color: white;padding: 15px 32px;text-align: center;text-decoration: none;display: inline-block;font-size: 16px;'>Click To Reset password</a>
    

【问题讨论】:

  • 是的,它看起来像一个按钮。那你的问题是什么??
  • @shrithi 问题不正确..我认为您需要将邮件作为 html 内容..其中应该有一个链接到重置密码的按钮吗?
  • 你试过带标题的邮件吗??

标签: php html css email


【解决方案1】:

您可以像这样在邮件中使用 HTML:

<?php
$to = "somebody@example.com, somebodyelse@example.com";
$subject = "HTML email";

$message = "<a href='http://example.com/PhpProject3/reset_passwd.php?key=".$email."&userid=".$userid."' style=' background-color: #4CAF50;border: none;color: white;padding: 15px 32px;text-align: center;text-decoration: none;display: inline-block;font-size: 16px;'>Click To Reset password</a>";
$message .= "Other Information ";

// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

// More headers
$headers .= 'From: <webmaster@example.com>' . "\r\n";
$headers .= 'Cc: myboss@example.com' . "\r\n";

mail($to,$subject,$message,$headers);
?> 

【讨论】:

    【解决方案2】:

    请试试这个:

    $html .= '<tr><td><a href='.base_url('customer_management/Approve_credit/reject_credit_limit/'.base64_encode($id).'/'.base64_encode('0').'/'.base64_encode($email_result['uidnr_admin'])).' style="background-color: #F32013;border: none;color: white;padding: 10px 20px;text-align: center;text-decoration: none;display: inline-block;font-size: 16px; margin-left:20px">Reject</a></td></tr>';
    

    【讨论】:

      【解决方案3】:

      试试这个

        <a href='http://example.com/PhpProject3/reset_passwd.php?key=".$email."&userid=".$userid."' style=' background-color: #4CAF50;border: none;color: white;padding: 15px 32px;text-align: center;text-decoration: none;display: inline-block;font-size: 16px;'>
          <button>Click To Reset password</button>
          </a>";
      

      【讨论】:

        猜你喜欢
        • 2016-07-09
        • 2023-01-31
        • 2019-05-20
        • 2014-04-05
        • 1970-01-01
        • 2012-01-14
        • 1970-01-01
        • 1970-01-01
        • 2021-05-21
        相关资源
        最近更新 更多