如何在PHP Mail函数中添加按钮?

时间:2017-11-17 05:34:45

标签: php html css email

我正在尝试使用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>
    

2 个答案:

答案 0 :(得分:2)

您可以在邮件中使用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);
?> 

答案 1 :(得分:-2)

试试这个

  <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>";