我已经有了一个联系人表单,我想给已经填写并发送表单的人添加一条自动回复消息,我该怎么做:(
$mail_sent = false;
if ( ! empty($_POST) && $_POST["first_name"] != "" )
{
// receiving a submission
$to = $_POST['department'];
// prep our data from the form info
$senderName = $_POST['first_name'];
$senderEmail = $_POST['email'];
$department = $_POST['department'];
$company = $_POST['company'];
$street = $_POST['street'];
$zip = $_POST['zip'];
$country = $_POST['country'];
$subjects = $_POST['subjects'];
$subject = "Message from Webpage Contact Form";
$messageBody = $senderName . '' . PHP_EOL . 'E-mail: ' . $senderEmail . '' . PHP_EOL . 'Company: ' . $company . '' . PHP_EOL . 'Street:
' . $street . '' . PHP_EOL . 'Zip: ' . $zip . '' . PHP_EOL . 'Country:
' . $country . '' . PHP_EOL . 'Subcject: ' . $subjects . '' . PHP_EOL . 'Comments: ' . $_POST['comments'];
if ( $department == 'customer' )
{
$to = 'mail0';
}
else
if ( $department == 'distribution' )
{
$to = 'mail1';
}
else
if ( $department == 'press' )
{
$to = 'mail2';
}
else
if ( $department == 'career' )
{
$to = 'mail3';
}
else
if ( $department == 'other' )
{
$to = 'mail4';
}
$send_contact = mail($to, $subject, $messageBody, $header);
if ( $send_contact )
{
header('Location: #');
}
else
{
echo "ERROR";
}
}发布于 2014-12-28 16:50:27
在这里:
$send_contact = mail($to, $subject, $messageBody, $header);变量$header未定义,因此不会发送任何邮件。
以下任一项:
$send_contact = mail($to, $subject, $messageBody);或者:
$header = "From: " . $senderEmail . "\r\n";
$send_contact = mail($to, $subject, $messageBody, $header);https://stackoverflow.com/questions/27674851
复制相似问题