我想在电子邮件正文本身的电子邮件表单中添加"此邮件来自 etcetc.com"。希望这是有道理的..
我的sent_email.php
<?php
$email_to = 'test@test.org';
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$headers = 'From: ' . $name . ' <' . $email . '>' . "'r'n" . 'Reply-To: ' . $email;
if(mail($email_to, $subject, $message, $headers)) {
echo 'sent'; // we are sending this text to the ajax request telling it that the mail is sent..
} else {
echo 'failed'; // ... or this one to tell it that it wasn't sent
}
?>
像这样:
<?php
$email_to = 'test@test.org';
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = "This message came from etcetc.com 'r'n".$_POST['message'];
$headers = 'From: ' . $name . ' <' . $email . '>' . "'r'n" . 'Reply-To: ' . $email;
if(mail($email_to, $subject, $message, $headers)) {
echo 'sent'; // we are sending this text to the ajax request telling it that the mail is sent..
} else {
echo 'failed'; // ... or this one to tell it that it wasn't sent
}
?>
您需要做的就是将文本添加到$message
末尾。
改变:
$message = $_POST['message'];
自
$message = $_POST['message'] . "'n'nThis message came from etcetc.com";
根据需要
在之前和之后添加消息
$message = "This is before posted message'r'n";
$message .= $_POST["message"];
$message .= "'r'nthis is after the posted message";