在PHP中的HTML格式的电子邮件的麻烦

时间:2017-08-09 04:23:35

标签: php html

我正在向其中一个用户发送批准/拒绝邮件。在该电子邮件中,我想显示一个按钮,以便当用户点击该按钮时,该请求可以被批准或拒绝。但他们的问题来了,当我收到邮件时,我看不到邮件中的按钮。代码如下。 请帮帮我。

             $to = $email;
             $subject = "Payment Confirmation";
             $headers = "MIME-Version: 1.0\n";
             $headers .= "Content-Type: text/html; charset=iso-8859-1\n";
             $headers .= "From: $email" . "\r\n" .
            "Reply-To: $email" . "\r\n" .
            'X-Mailer: PHP/' . phpversion();
            $message = '<html><head><!-- Latest compiled and minified CSS - 
           ->
         <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

    <!-- Optional theme -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

     <!-- Latest compiled and minified JavaScript -->
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
    </head><body>';
     $message .= '<h1 CONFIRMATION EMAIL</h1>';
    $message .= '<p> <?php echo($name) ?> has reuqested payment. Kindly approve or 
                disapprove the requets</p>';
               $message .='<button class="btn btn-success" type="button"> <a 
              href="approveR.php"></a>APPROVE</button>';
             $message .= '</body></html>';

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

1 个答案:

答案 0 :(得分:0)

使用此代码:

<?php
$to = $email;
$subject = "Payment Confirmation";
$headers = "From: " . $email . "\r\n";
$headers .= "Reply-To: ". $email . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

$message = '<html><head><!-- Latest compiled and minified CSS -->
            <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

            <!-- Optional theme -->
            <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

            <!-- Latest compiled and minified JavaScript -->
            <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
            </head><body>';
            $message .= '<h1 CONFIRMATION EMAIL</h1>';
            $message .= '<p> '. $name .' has reuqested payment. Kindly approve or 
            disapprove the requets</p>';
            $message .='<button class="btn btn-success" type="button"> <a 
            href="approveR.php"></a>APPROVE</button>';
$message .= '</body></html>';

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