我在我继承的网站上有一个联系表格。我不知道消息来源。我需要用户使用不同的消息接收电子邮件的副本。有人可以帮忙吗?
这是PHP
// Adding e-mail headers
$headers = "";
if (FROM_EMAIL !== '') {
$headers .= 'From: '.FROM_EMAIL."\r\n";
}
$headers .= 'Reply-To: '.$contact_email."\r\n";
$headers .= 'Content-Type: text/plain; charset=UTF-8'."\r\n";
/*
* Formatting message.
* It can be customizable in any way you like.
*/
$title = 'Contact Form - New Message from '.$contact_name;
$message = 'Hi,'."\n\n"
.'You have received new message from your website. Check details below:'."\n\n"
.'Sender\'s IP address: '.getIp()."\n\n"
.'Name: '.$contact_name."\n\n"
.'Title: '.$contact_sex."\n\n"
.'E-mail: '.$contact_email."\n\n"
.'Phone number: '.$contact_tel."\n\n"
.'Selected department: '.$contact_department."\n\n"
.'Message:'."\n\n"
.$contact_message;
// Mail it!
$result = mail(TO_EMAIL, $title, $message, $headers);
// Notify contact form about result of sending.
if ($result) {
$json['result'] = 'OK';
} else {
$json['result'] = 'SEND_ERROR';
}
header('Access-Control-Allow-Origin: *');
echo json_encode($json);
die();
}
答案 0 :(得分:3)
替换:
// Mail it!
$result = mail(TO_EMAIL, $title, $message, $headers);
有了这个:
$differentMessage = 'This is a string that contains sth and after this we append the old message' . $message;
// Mail it!
$result = mail(TO_EMAIL, $title, $message, $headers);
// Mail a copy
mail($contact_email, $title, $differentMessage, $headers);
请注意,标题将保持不变(重播),但这可以让您了解如何修改变量并发送第二封电子邮件。