我希望通过我的网站上的联系表单发送电子邮件,以显示从用户的邮箱发送(例如,用户以联系方式指定他的电子邮件为'john1233@gmail.com' - 我希望此电子邮件被视为直接发送给他,并有适当的回复选项)。
我试图自己修改这个脚本,没有成功:(我对php不是很精通,所以任何帮助都会非常感激!!
这是我使用的脚本:
<?php
if(isset($_POST['email'])) {
$email_to = "my email";
$email_subject = "mail subject";
// validation here
$name = $_POST['name']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['telephone']; // not required
$comments = $_POST['comments']; // required
// error messages here
$error_message = "";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .='my html code'
;
// create email headers
$headers = 'From: '.$email_from."\r\n".
$headers = "MIME-Version: 1.0\r\n";
$headers = "Content-type: text/html; charset=utf-8\r\n";
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
答案 0 :(得分:1)
应该是:
$headers = 'From: '.$email_from."\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-type: text/html; charset=utf-8\r\n" .
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();