Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何将自定义邮件添加到我的表单邮件程序中_Php - Fatal编程技术网

Php 如何将自定义邮件添加到我的表单邮件程序中

Php 如何将自定义邮件添加到我的表单邮件程序中,php,Php,我想在电子邮件正文中的电子邮件表单中添加“此邮件来自etcetc.com”。希望这有意义 my sent_email.php <?php $email_to = 'test@test.org'; $name = $_POST['name']; $email = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['message']; $headers = 'From: ' . $name . ' <

我想在电子邮件正文中的电子邮件表单中添加“此邮件来自etcetc.com”。希望这有意义

my 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    
}

您只需将文本添加到
$message
的末尾即可

更改:

$message=$\u POST['message']

$message=$\u POST['message']。“\n\n此消息来自etcetc.com”

如下:

<?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 = "This is before posted message\r\n";
$message .= $_POST["message"];
$message .= "\r\nthis is after the posted message";

你遇到的问题是什么?考虑追加到<代码> $消息< /代码>