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

查看:178
本文介绍了更改发件人名称php邮件而不是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 . "\r\n" .
               "X-Mailer: PHP/" . phpversion();
    $headers .= 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";        
    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 头。

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 . "\r\n";

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

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