header function mail() php


header function mail() php

我必须使用PHP的函数mail()发送邮件。我必须插入回复标题,但它不起作用:

<?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";但如果复制并粘贴此邮件,然后发送邮件,则没有"答复"标头。如果在我的HTML邮件中插入其他标头,如"发件人"、"抄送"、"密件抄送",则只有"答复"标题没有。我试过像"回复","回复"回复"等,但它不起作用。我用过Php 5.4能帮我吗?

试试这个。

为收件人、主题和邮件添加参数。

那么在这条线上"返回邮件($receiver,$subject,$message,$headers);"

将$message替换为$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);
?>

希望它能帮助你