头函数mail()php [英] header function mail() php
问题描述
我必须使用PHP函数mail()发送邮件。
我必须插入Reply-To标头,但不起作用:
i have to send mail with function mail() of PHP. I have to insert Reply-To header but it not work:
<?php
$body = "<html>\n";
$body .= "<body style=\"font-family:Verdana, Verdana, Geneva, sans-serif; font-size:12px; color:#666666;\">\n";
$body = $message;
$body .= "</body>\n";
$body .= "</html>\n";
$headers = "From: My site<noreply@example.com>\r\n";
$headers .= "Reply-To: info@example.com\r\n";
$headers .= "Return-Path: info@example.com\r\n";
$headers .= "X-Mailer: Drupal\n";
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
return mail($recipient, $subject, $message, $headers); ?>
在php.net的此示例中,有$ headers。=回复至:info @ example .com\r\n;但是,如果复制并粘贴此内容,然后将其发送给Reply-To标头则没有。如果插入其他标头,例如发件人,抄送,密件抄送这些正确在我的HTML邮件中,则只有Reply-To标头没有。
我尝试过像答复,答复,答复,答复等,但是它不起作用。
我已经使用PHP 5.4可以帮助我吗?
In this example of php.net there is $headers .= "Reply-To: info@example.com\r\n"; but if copy and paste this and then send mail the Reply-To header there is not. If insert other header like From, CC, Bcc these there are correctly in my HTML mail, only Reply-To header there is not. I have try like "Reply-to", "Reply to", "Reply To", "Reply" etc but it not work. I have use Php 5.4 can help me?
推荐答案
尝试一下。
为收件人,主题,
然后在此行
返回邮件($ recipient,$ subject,$ message,$ headers);
then at this line " return mail($recipient, $subject, $message, $headers); "
将$ message替换为$ body。
replace the $message into $body.
看起来像这样
<?php
$recipient = "jack@example.com";
$subject = "test subject";
$message = "test message";
$body = "<html>\n";
$body .= "<body style=\"font-family:Verdana, Verdana, Geneva, sans-serif; font-size:12px; color:#666666;\">\n";
$body = $message;
$body .= "</body>\n";
$body .= "</html>\n";
$headers = "From: My site<noreply@example.com>\r\n";
$headers .= "Reply-To: info@example.com\r\n";
$headers .= "Return-Path: info@example.com\r\n";
$headers .= "X-Mailer: Drupal\n";
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$result = mail($recipient, $subject, $body, $headers);
var_dump($result);
?>
希望它将对您有帮助
这篇关于头函数mail()php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!