【问题标题】:Style Php contact form mail样式 PHP 联系表格邮件
【发布时间】:2013-02-11 01:50:54
【问题描述】:

我想知道如何设置 $body =" 部分的样式,以便让我收到的电子邮件更易于阅读。

我已经尝试过添加标签或正文标签之类的方法,但似乎都不起作用,请帮我解决这个烦人的问题,

非常感谢,

昆西

<?php
                    $name = $_POST['name'];
                    $email = $_POST['email'];
                    $message = $_POST['message'];
                    $from = 'From: info@epicconcepts.nl'; 
                    $to = 'info@epicconcepts.nl'; 
                    $subject = 'Contact formulier bericht';
                    $human = $_POST['human'];

                    $headers = "From: " . strip_tags($_POST['req-email']) . "\r\n";
                    $headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n";
                    $headers .= "CC: quincynorbert@live.nl\r\n";
                    $headers .= "MIME-Version: 1.0\r\n";
                    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

                    $body = "
                    New Mail $name\n $email\n \n $message";

                    if ($_POST['submit']) {
                        if ($name != '' && $email != '') {
                            if ($human == '4') {                 
                                if (mail ($to, $subject, $body, $from)) { 
                                echo '<p class="correct-message">Your message has been sent!</p>';
                            } else { 
                                echo '<p class="correct-message">Something went wrong, go back and try again!</p>'; 
                            } 
                        } else if ($_POST['submit'] && $human != '4') {
                            echo '<p class="correct-message">You answered the anti-spam question incorrectly!</p>';
                        }
                        } else {
                            echo '<p class="correct-message">You need to fill in all required fields!</p>';
                        }
                    }
                ?>

【问题讨论】:

  • 只需将有效的 html 代码添加到 $body var 中即可?
  • 添加标签时会发生什么?它们没有效果吗?

标签: php forms contact


【解决方案1】:

如果您只是使用 css 样式(如 style="correct-message") - 这不起作用,您也应该在 body 中添加样式定义,如下所示:

<style> .correct-message{font-weight:bold; color:red;}</style>

【讨论】:

  • 你能再解释一下吗?也许是一个例子?
  • 简单 html:code$body = "新邮件姓名: $name
    电子邮件: $电子邮件

    $message

    ";code
猜你喜欢
  • 1970-01-01
  • 2012-11-01
  • 2013-11-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多