PHP Sendmail不工作

时间:2014-07-13 15:21:49

标签: php html sendmail

我正在为我公司的网站工作,我希望客户能够填写HTML表格并让它通过php向我和我的客户发送电子邮件。这是我的代码,现在当我填写表单后点击提交我得到我的php回声,但是没有电子邮件发送。提前致谢! (两个代码都在一个名为quotes.php的文件中)

<form action="quotes.php" method="post">
            Name: <input type="text" name="name" required="yes"><br>
            Email Address: <input type="email" name="email" required="yes"><br>
            Phone: <input type="text" name="phone" required="yes"><br>
            Home or Business?: <input type="text" name="horb" required="yes"><br>
            Number of int. Cameras Desired: <input type="number" name="extcam"><br>
            Number of ext. Cameras Desired: <input type="number" name="intcam"><br>
            Number of ext. Doors: <input type="number" name="exdrs"><br>
            Do/Don't want Automated Door Locks?: <input type="text" name="locks"><br>
            Number of 1st Floor Windows: <input type="number" name="winds"><br>
            Number of Windows on Other Floors: <input type="number" name="otherwinds">     <br>
            Do/Don't want Energy Control?: <input type="text" name="energy"><br>
            Number of Switches to be Controlled:<input type="number" name="switches"><br>
            Number of Outlets to be Controlled:<input type="number" name="outlets"><br>
            Do/Don't want Automated Thermostat?: <input type="text" name="temp"><br>
            <textarea type="text" rows="4" cols="50" name="comments">Any additional devices/comments...</textarea><br>
            <input type="submit" value="Submit" name="submit"><br>
            <small>*Please note a walk-through of the property may be neccessary before a final price can be determined.</small>
        </form>

<?php
if(isset($_POST['submit'])){
    $to = "norcalhomeautomation@gmail.com";
    $from = $_POST['email'];
    $name = $_POST['name'];
    $subject = "Quote form submission!";
    $subject2 = "Confirmation of your Quote Request";
    $message = $name . " requested a quote for their " . $_POST['horb'] . ":" . "\n\n" . "The customer requested " . $_POST['extcam'] . " exterior cameras and " . $_POST['intcam'] . " interior cameras. They have " . $_POST['extdrs'] . " exterior doors they " . $_POST['locks'] . " want automated locks for. They have " . $_POST['winds'] . " windows on the first floor and " . $_POST['otherwinds'] . " other windows. They " . $_POST['energy'] . " want energy control and they have " . $_POST['switches'] . " switches and " . $_POST['outlets'] . " outlets to be replaced. They " . $_POST['temp'] . " want an automated thermostat. The customer commented the following:" . "\n\n" . $_POST['comments'] . ". You may contact them at either " . $_POST['email'] . " or " . $_POST['phone'] . "at your earliest convenience.";
    $message2 = "Thank you for your quote request " . $_POST['name'] . "! This email is to confirm your quote was successfully received by NorCal Home Automation. A representative from NorCal will contact you shortly at either " . $_POST['email'] . " or " . $_POST['phone'] . ". If this contact information was entered incorrectly please email NorCalHomeAutomation@gmail.com to update your contact information. Thank you for your interest in NorCal Home Automation we look forward to having you as a satisfied customer!";

    $headers = "From:" . $from;
    $headers2 = "From:" . $to;
    mail($to,$subject,$message,$headers);
    mail($from,$subject2,$message2,$headers2);
    echo "Thank you " . $name . " your quote was submitted, please check your email for confirmation.";
    }
?>

1 个答案:

答案 0 :(得分:0)

您可能需要检查并查看php实例是否配置为允许使用mail()命令。

此外,不是使用两个单独的命令,而是嵌入&#34;密送:&#34;在这样的标题中:

$headers.= "Bcc: $from\n";