我是否将mimetype设置为错误?或为了成功发送电子邮件我需要做什么

时间:2018-11-16 18:14:06

标签: php html css web-development-server

由于我相对较新,因此我尝试使用php。我想知道当用户填写所有必填字段时,要成功发送电子邮件需要做什么(此示例中未显示。基本上,如果我填写“名和姓”,“电话号码”字段,电子邮件和消息字段”,我实际上是尝试使用html和css向客户端(无论谁接收电子邮件的人)发送格式良好的电子邮件,但在这种情况下,我会将整个html语法发送给用户而不是实际发送用户键入的“文本”。

 $email_content =
                "
                <!DOCTYPE html>
                <html>
                <head>
                <title>$subject</title>
                <link href=\"https://fonts.googleapis.com/css?family=Niconne\" rel=\"stylesheet\">
                <link href=\"https://fonts.googleapis.com/icon?family=Material+Icons\" rel=\"stylesheet\">
                <link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css\">
                <link rel=\"stylesheet\" href=\"https://cdn.iconmonstr.com/1.3.0/css/iconmonstr-iconic-font.min.css\">
                <link rel=\"stylesheet\" href=\"/css/bootstrap-grid.css\"> 
                <link rel=\"stylesheet\" href=\"https://use.fontawesome.com/releases/v5.5.0/css/all.css\" integrity=\"sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU\" crossorigin=\"anonymous\">
                </head>

                <body>
                    <div class=\"container\">
                        <div class=\"row\">
                            <div class=\"col-12 text-center\">
                            <a href=\"https://www.snizzyDragonsTest.com/\" target=\"_blank\" class=\"btn btn-primary ml-auto\">Visit Website </a>
                            </div>
                            <br>
                            <br>
                            <br>
                            <div class=\"col-12 green-color-bg\">


                                <p class=\"text-head\" style=\"font-family: 'Niconne'; \"> snizzyDragonsTest</p>

                            </div>
                            <div class=\"col-12 white-color-bg text-center\">
                                <p class=\"text-head-email green-text greys-color-bg \" style=\"font-family: 'Roboto';  \" >Name:<span style =\"color: #555;\">$first $last</span></p>
                                <p class=\"text-head-email green-text greys-color-bg \" style=\"font-family: 'Roboto';  \" >Email: <span style =\"color: #555;\">$email</span></p>
                                <p class=\"text-head-email green-text greys-color-bg \" style=\"font-family: 'Roboto';  \" >Phone: <span style =\"color: #555;\">$phone</span></p>
                                <p class=\"text-head-email green-text greys-color-bg \" style=\"font-family: 'Roboto';  \" >Inquiring About: <span style =\"color: #555;\">$products</span></p>
                                <p class=\"text-head-email green-text greys-color-bg \" style=\"font-family: 'Roboto';  \" >Message: <span style =\"color: #555;\">$message</span></p>
                            </div>
                            <div class =\"col-12 green-color-bg\">

                            <div class=\"footer-copyright text-center  py-3\">snizzyDragonsTest &copy;2018 Copyright. All rights reserved.</div>
                            </div>
                        </div>
                    </div>
                </body>
                </html>
                ";







    // Build the email headers.
    $email_headers = "MIME-Version: 1.0" . "\r\n";
    $email_headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

    // Additional headers
    $email_headers .= 'From: $first $last  <$email>' . "\r\n";



    // Send the email.
    mail($recipient, $subject, $email_content, $email_headers);

输出(预期输出) enter image description here

输出(实际输出) enter image description here

0 个答案:

没有答案