0

在研究了几个问题并尝试了多种选择之后,我仍然无法让它工作!

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

<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>&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( "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”并收到一封电子邮件!但是然后将所有其他选项放回原处,再无...

有人可以帮助我吗?

非常感谢您!:)

4

2 回答 2

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;
于 2013-03-01T07:50:04.460 回答
0

尝试将所有信息添加到标题元素:

$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 的文件,或者只是回显它

于 2013-03-01T08:26:43.643 回答