在研究了几个问题并尝试了多种选择后,我无法让它继续工作!
我有这个不会发送的联系表格。
<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="yourmail@domain.com" 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> </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> </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( "formulario@ourdreamjourney.com", "rsvp",
"Name: $name\nEmail: $email\nPhone: $phone\nRsvp: $rsvp\nMenu: $menu\nMas: $mas\nMessage: $message\n",
"From: Our Dream Journey <mail@hotmail.com>" );
我随机尝试发送“姓名:$ name”,我收到了一封电子邮件!但是然后又把所有其他选项都放回去了......
有人可以帮我吗?
提前非常感谢! :)
答案 0 :(得分: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 <mail@hotmail.com>' . "\r\n";
if(mail( "formulario@ourdreamjourney.com", "rsvp",nl2br("Name: $name\nEmail: $email\nPhone: $phone\nRsvp: $rsvp\nMenu: $menu\nMas: $mas\nMessage: $message\n"),
$headers )) echo "Sent"; die;
答案 1 :(得分:0)
尝试将所有信息添加到header元素:
$headers = "From: myplace@here.com\r\n";
$headers .= "Reply-To: myplace2@here.com\r\n";
$headers .= "Return-Path: myplace@here.com\r\n";
$headers .= "CC: sombodyelse@noplace.com\r\n";
$headers .= "BCC: hidden@special.com\r\n";
也许还有其他选项,我不记得像MIME一样
也许另一个问题是某些变量会破坏字符串(关闭字符串)。尝试在某个地方打印它,一个带有file_put_contents的文件或只是回显它