0

好的,我正在使用 jQuery mobile,我只是为电子邮件表单输入了一个 PHP 脚本。一切都很好,除了没有任何东西发送到我的收件箱。这是表单和php代码,真的可以在这里使用一些帮助。一直在挠我的大脑最长时间。

<?php
if($_SERVER['REQUEST_METHOD'] == "POST") 
{
    $message_body = 'First Name: ' . $_POST['firstName'] . '
            Last Name: ' . $_POST['lastName'] . '
            Email: ' . $_POST['email'] . '
            Company: ' . $_POST['company'] . '
            Phone: ' . $_POST['phone'] . '
            Services: ' . $_POST['serviceAreas'] .'
            Message: ' . $_POST['comments'];

    $to      = 'marvin.fai2@gmail.com';
    $subject = 'MobilizeWorldwide.com Contact Submission';
    $message = $message_body;
    $headers = 'From: info@mobilizeworldwide.com' . "\r\n" .
            'Reply-To: ' . $_POST['email'] . "\r\n" .
            'X-Mailer: PHP/' . phpversion();

    mail($to, $subject, $message, $headers);

    header('Location: ' . $_POST['thankspage']);
}
else
{
    echo 'There is no post information.';
}

HTML:

 <form method="post" action="email.php">
          <input type="text" name="firstName" placeholder="First name" required>
          <input type="text" name="lastName" placeholder="Last name" required>
          <input type="text" name="email" placeholder="Email Address" required>
          <input type="text" name="company" placeholder="Company">
          <input type="text" name="phone" placeholder="Phone Number">
          <fieldset>
            <legend>Please indicate service areas of interest, and select all that apply:</legend>
            <input id="airFrame" name="serviceArea" type="checkbox">
            <label for="airFrame">VISA</label>
            <input id="compMaint" name="serviceArea" type="checkbox">
            <label for="compMaint">AmEx</label>
            <input id="engineAPU" name="serviceArea" type="checkbox">
            <label for="engineAPU">Mastercard</label>
            <input id="engineAPULeas" name="serviceArea" type="checkbox">
            <label for="engineAPULeas">VISA</label>
            <input id="lMaint" name="serviceArea" type="checkbox">
            <label for="lMaint">AmEx</label>
            <input id="gTS" name="serviceArea" type="checkbox">
            <label for="gTS">Mastercard</label>
            <input id="onW" name="serviceArea" type="checkbox">
            <label for="onW">VISA</label>
            <input id="train" name="serviceArea" type="checkbox">
            <label for="train">AmEx</label>
          </fieldset>
          <textarea id="comments" name="comments" placeholder="Comments" rows="8"></textarea>
          <button type="submit" value="Submit" name="submit">
        </form>
4

1 回答 1

0

我没有考虑您的 html 表单,因为我相信您的 post 方法可以正常工作,并且 email.php 会按照您的设置获取所有值,在我的情况下,我假设使用虚拟值来检查您的脚本,

<?php

$message_body = 'First Name: ' . "tariq" . '
        Last Name: ' . "sarwar" . '
        Email: ' . "mts@gmail.com" . '
        Company: ' . "renai" . '
        Phone: ' . "123456" . '
        Services: ' . "abcdef" .'
        Message: ' . "Test message" ;

$to      = 'mtarik.sarwar@gmail.com';
$subject = 'MobilizeWorldwide.com Contact Submission';
$message = $message_body;
$headers .= 'From: "user" <user@domain.com>' . "\r\n";

if(mail($to, $subject, $message, $headers)) echo "msg sent"; else echo '没有发布信息。';

?>

正如我之前提到的那样,我得到了结果,但作为 gmail 的垃圾邮件,并且在其他邮件服务器上工作正常;

在此处输入图像描述

于 2012-03-29T14:24:47.007 回答