2013-03-01 227 views
0

经过研究几个问题,并尝试多个选项,我不能让它仍然工作!Php邮件功能将不起作用

我有这个不会发送的联系表。

<form id="contact" method="post" action="process.php"> 
    <fieldset> 

     <label for="name">Name:</label> 
     <input type="text" name="name" placeholder="Your name" title="Your name" class="required"> 

     <label for="email">E-mail:</label> 
     <input type="email" name="email" placeholder="[email protected]" title="Your e-mail address" class="required email"> 

     <label for="phone">Phone number:</label> 
     <input type="tel" name="phone" placeholder="+34 111 22 33 44" title="Your phone number"> 

     <p>&nbsp;</p> 
     <input type="radio" name="rsvp" value="si"> 
     <span class="destacar-contacto">ACCEPT</span> the invitation<br> 
     <input type="radio" name="rsvp" value="no"> 
     <span class="destacar-contacto">REJECT</span> the invitation<br> 

     <p>&nbsp;</p> 
     <p class="negrita-contacto">If you're coming: what would you like better?</p> 
     <input type="radio" name="menu" value="carne"> Calf sirloin with foie<br> 
     <input type="radio" name="menu" value="pescado"> Marinade salmon with dill<br> 
     <input type="radio" name="menu" value="vegetariano"> Fungus risotto<br> 

     <label for="mas">Is someone coming with you? Let us know their name and their prefered menu here:</label> 
     <textarea name="mas"></textarea> 

     <label for="message">Aditional message:</label> 
     <textarea name="message"></textarea> 

     <input type="submit" name="submit" class="boton" id="submit" value="Enviar" /> 

    </fieldset> 
</form> 

这是PHP函数:

$name = strip_tags($_POST['name']); 
$email = strip_tags($_POST['email']); 
$phone = strip_tags($_POST['phone']); 
$rsvp = strip_tags($_POST['rsvp']); 
$menu = strip_tags($_POST['menu']); 
$mas = strip_tags($_POST['mas']); 
$message = strip_tags($_POST['message']); 

mail("[email protected]", "rsvp", 
"Name: $name\nEmail: $email\nPhone: $phone\nRsvp: $rsvp\nMenu: $menu\nMas: $mas\nMessage: $message\n", 
"From: Our Dream Journey <[email protected]>"); 

我试图随机派只是“姓名:$名称”和我的电子邮件!但后来把所有其他选项,并没有再次...

有人可以帮助我吗?

非常感谢你提前! :)

+0

你试着只发送一封邮件('[email protected]','测试','消息'); ' – 2013-03-01 07:48:32

+0

垃圾邮件过滤器正在阻止它。当邮件未收到垃圾邮件关键字时,请查看邮件的内容?同样为了调试你应该检查'mail()'的返回值,看看它是否被接收。 – MrCode 2013-03-01 07:53:33

+0

@MarinSagovac是的,我试过了,它工作,所以我认为这可能是这一行的问题:“名称:$ name \ nEmail:$ email \ n电话:$ phone \ nRsvp:$ rsvp \ nMenu:$ menu \ nMas :$ mas \ nMessage:$ message \ n“ – 2013-03-01 09:38:25

回答

0

您可以使用phpMailer类。从这里下载这个库。很多例子都可以发送电子邮件。

http://code.google.com/a/apache-extras.org/p/phpmailer/downloads/list

编辑:

试试这个代码

$headers = 'MIME-Version: 1.0' . "\r\n"; 
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 

    // Additional headers 
    $headers .= 'From:Our Dream Journey <[email protected]>' . "\r\n"; 

    if(mail("[email protected]", "rsvp",nl2br("Name: $name\nEmail: $email\nPhone: $phone\nRsvp: $rsvp\nMenu: $menu\nMas: $mas\nMessage: $message\n"), 
    $headers)) echo "Sent"; die; 
+0

Kya baat hai先生:-) – ravisoni 2013-03-01 10:46:30

0

尝试将所有的信息添加到头元素:

$headers = "From: [email protected]\r\n"; 
$headers .= "Reply-To: [email protected]\r\n"; 
$headers .= "Return-Path: [email protected]\r\n"; 
$headers .= "CC: [email protected]\r\n"; 
$headers .= "BCC: [email protected]\r\n"; 


也许还有其他的选项,我不记得像MIME
也许另一个问题是,一些变量破坏字符串(关闭字符串)。尝试打印它的地方,一个文件file_put_contents或只是回声它