确认电子邮件显示服务器详细信息而不是noreply电子邮件

时间:2017-09-20 08:26:31

标签: php email

我使用此脚本不仅向注册人的域发送电子邮件,还向发送邮件的人发送确认电子邮件给注册人。 php块是:

<?php
if( isset($_POST['n']) && isset($_POST['e']) && isset($_POST['tel']) && isset($_POST['subject']) && isset($_POST['m'])){
    $n = $_POST['n'];
    $e = $_POST['e'];
    $s = $_POST['subject'];
    $t = $_POST['tel'];
    $m = nl2br($_POST['m']);
    $to = "info@domain.com";
//    $from = $e;
    $subject = 'Contact Form Message';
    $message = '<b>Name:</b> '.$n.' <br><b>Email: '.$e.'</b><br>Subject: '.$s.'<p>'.$m.'</p>';
    $conf_sender = 'Name of company <no-reply@domain.com>';
    $conf_mess = "Dear ".$n."\nThank you for your enquiry. Your message has been sent and will be sent and will be dealt with shortly.\nPlease wait for a reply";
    $conf_mess .="\nYour Message: ".$m."\n";
    $conf_mess .="MIME-Version: 1.0\n";
    $conf_mess .="Content-type: text/html; charset=iso-8859-1\n";
    $headers = "From: $e\n";
    $headers .="MIME-Version: 1.0\n";
    $headers .="Content-type: text/html; charset=iso-8859-1\n";
    if( mail($to, $s, $message, $headers) ){
        mail($e,$s,$conf_mess,$conf_sender);
        echo "success";
    } else {
        echo "The server failed to send the message. Please try again later.";
    }
}
?>

这也出现在电子邮件的末尾,不应该显示

  

MIME-Version:1.0 Content-type:text / html;字符集= ISO-8859-1

1 个答案:

答案 0 :(得分:1)

您发送 2封邮件 2条不同消息第一封邮件 $ message ,第二封 $ conf_mess 所以看看你放的是什么,这是正常的:

因为你连续到$ conf_mess这个:

$ conf_mess。=“内容类型:text / html; charset = iso-8859-1 \ n”;

if( mail($to, $s, $message, $headers) ){
    mail($e,$s,$conf_mess,$conf_sender);

你想要这个:

<?php
if( isset($_POST['n']) && isset($_POST['e']) && isset($_POST['tel']) && isset($_POST['subject']) && isset($_POST['m'])){
    $n = $_POST['n'];
    $e = $_POST['e'];
    $s = $_POST['subject'];
    $t = $_POST['tel'];
    $m = nl2br($_POST['m']);
    $to = "info@domain.com";
//    $from = $e;
    $subject = 'Contact Form Message';
    $message = '<b>Name:</b> '.$n.' <br><b>Email: '.$e.'</b><br>Subject: '.$s.'<p>'.$m.'</p>';

    $conf_sender = 'Name of company <no-reply@domain.com>';
    $conf_sender .="MIME-Version: 1.0\n";
    $conf_sender .="Content-type: text/html; charset=iso-8859-1\n";
    $conf_mess = "Dear ".$n."\nThank you for your enquiry. Your message has been sent and will be sent and will be dealt with shortly.\nPlease wait for a reply";
    $conf_mess .="\nYour Message: ".$m."\n";


    $headers = "From: $e\n";
    $headers .="MIME-Version: 1.0\n";
    $headers .="Content-type: text/html; charset=iso-8859-1\n";
    if( mail($to, $s, $message, $headers) ){
        mail($e,$s,$conf_mess,$conf_sender);
        echo "success";
    } else {
        echo "The server failed to send the message. Please try again later.";
    }
}
?>