将此表单发送到电子邮件

时间:2015-01-21 23:24:56

标签: php forms

我在理解如何告诉此特定表单发送到电子邮件时遇到问题。我看到它正在发送到数据库。我会加一个$ to = $ _POST ['email@email.com'];任何帮助将不胜感激。

同样在html(由CMS生成)表单action =“#3”所以我甚至不确定我找到的这个php文件是否是我正在寻找的那个。我的大脑在融化。

if (isset($_REQUEST["submitted"])) {


    # ---------------------------------------------- SEND THE MAIL

    $mailAddress = $mailContact;
    $mailSubject = "From the Contact Form at " . $siteName;

    if (strstr($_REQUEST["email"], "@")) {
        $mailHead = "From: " . $_REQUEST["email"] . "\r\n";
    } else {
        $mailHead = "From: " . $mailContact . "\r\n";
    }

    $mailMsg = "";
    $mailMsg .= "The following information was submitted at " . $siteName . ":\n\n";
    $mailMsg .= "Name: " . $_REQUEST["gname"] . "\n";
    $mailMsg .= "Email: " . $_REQUEST["email"] . "\n";
    $mailMsg .= "Phone: " . $_REQUEST["phone"] . "\n\n";
    $mailMsg .= "Message:\n\n";
    $mailMsg .= $_REQUEST["msg"];

    $mailMsg = stripslashes($mailMsg);

    if ($useMail == "yes") {
        mail($mailAddress, $mailSubject, $mailMsg, $mailHead);
    }

    # ---------------------------------------------- WRITE TO DATA

    $SQL = "INSERT INTO " . $pfx . "Contact (ClientID, AddDate, AddTime, GName, Phone, Email, Message) VALUES (";
    $SQL .= $_REQUEST["clientid"] . ", '";
    $SQL .= WriteDate(StraightDate(localtime())) . "', '";
    $SQL .= GetTime(localtime()) . "', '";
    $SQL .= clean($_REQUEST["gname"]) . "', '";
    $SQL .= clean($_REQUEST["phone"]) . "', '";
    $SQL .= clean($_REQUEST["email"]) . "', '";
    $SQL .= clean($_REQUEST["msg"]) . "')";

    DoQuery1($SQL);

    # ------------------------------------------ SHOW CONFIRMATION

}

?><table width="350" cellpadding="0" cellspacing="0"><tr><td><span class="pageCopy">

    Thanks for taking the time to write to us. If your message requires 
    a response, someone at <?=$siteName?> will be in
    touch with you as soon as possible.

    <br><br><br><br>
    <br><br><br><br>
    <br><br><br>

</span></td></tr></table><br><br>

2 个答案:

答案 0 :(得分:0)

您只需一眼就可以将$ mailAddress设置为$ mailContact。邮件功能跟随邮件('TO','Subject','Message','Head')。因此,您可以尝试将邮件更改为。

$to = $_POST['email@email.com'];

if ($useMail == "yes") {
    mail($to, $mailSubject, $mailMsg, $mailHead);
}

答案 1 :(得分:0)

电子邮件功能在这里:

if ($useMail == "yes") {
    mail($mailAddress, $mailSubject, $mailMsg, $mailHead);
}

我要检查的第一件事是$ useMail被设置为“是”

您将获得有关邮件功能here

的更多信息