[英]Sending a copy of email to sender in PHP
我在繼承的網站上有聯系表格。 我不知道來源。 我需要用戶接收帶有不同消息的電子郵件副本。 有人可以幫忙嗎?
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();
}
更換:
// 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);
請注意,標頭將保持不變(重播),但這應使您對如何修改變量和發送第二封電子郵件有所了解。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.