更改发件人名称 php mail 而不是 sitename@hostname.com [英] Change the sender name php mail instead of sitename@hostname.com

查看:19
本文介绍了更改发件人名称 php mail 而不是 sitename@hostname.com的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从我的 php 发送电子邮件:

I am trying to send email from my php :

$to = 'it@7sisters.in';
    $email_from = "info@7sisters.in";

    $full_name = 'Suraj Hazarika';
    $from_mail = $full_name.'<'.$email_from.'>';



    $subject = "testing sender name";
    $message = "";
    $message .= '
            <p><strong>This is only a test . Please do not reply.</strong><br />
    ';
    $from = $from_mail;

    $headers = "" .
               "Reply-To:" . $from . "
" .
               "X-Mailer: PHP/" . phpversion();
    $headers .= 'MIME-Version: 1.0' . "
";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "
";        
    mail($to,$subject,$message,$headers);

我正在学习教程 PHP 电子邮件表单发件人姓名而不是电子邮件?但我仍然收到带有主机名的发件人姓名的电子邮件.

I am following the tutorial PHP E-mail Form Sender Name Instead Of E-mail? but I am still getting the emails with sender name with hostname.

     From                              Date             Subject 
sisters@rsx02.justhost.com  Fri, 11:24 pm       testing sender name
sisters@rsx02.justhost.com  Fri, 11:24 pm       testing sender name

推荐答案

您只能在 Reply-To 标题中使用 $from.如果你想让它在 From 标头中,你需要在 From 标头中设置它.

You only use $from in your Reply-To header. If you want it to be in the From header, you need to set it in the From header.

在您的 mail() 命令之前放置类似的内容:

Put something like this before your mail() command:

$headers .= 'From: ' . $from . "
";

这篇关于更改发件人名称 php mail 而不是 sitename@hostname.com的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆