2013-02-11 64 views
0

我想知道如何风格的$身体=”的一部分,所以我进来的电子邮件更友好的阅读。风格的PHP接触形式的邮件

我已经尝试了一些东西,比如添加标签或body标签,但是这一切似乎没有工作,请帮我解决这个恼人的问题,

许多方面,

昆西

<?php 
        $name = $_POST['name']; 
        $email = $_POST['email']; 
        $message = $_POST['message']; 
        $from = 'From: [email protected]'; 
        $to = '[email protected]'; 
        $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: [email protected]\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>'; 
         } 
        } 
       ?> 
+0

只需将有效的html代码添加到$ body var? – Philipp 2013-02-11 01:53:30

+0

添加标签时会发生什么?他们没有效果吗? – karancan 2013-02-11 02:32:02

回答

0

如果你只是使用CSS样式(如风格=”正确的消息“) - 这是行不通的,你应该在体内添加样式定义,像这样:

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

你能解释一下吗?也许是一个例子? – 2013-02-11 13:26:27

+0

简单的HTML:'code' $身体= “新邮件名称: $命名
电子邮件: $电子邮件

$消息

”;'code' – 2013-02-12 05:39:13