dtz8044 2017-02-09 12:14
浏览 280

如何让PHPMailer忽略'from'电子邮件地址并仅显示名称?

I'm using PHPMailer with the same SMTP configuration as my outlook.

Let's say that my email is "b@example.com" and name is "Bob, b". When I send a mail from my outlook to "Alice" at "a@example.com". In her outlook client she will only see "Bob, b" and she will not see my email address in the header.

When sending the same mail from "PHPMailer" Alice will see in her outlook "Bob, b {b@example.com}"

When I tried to set it without the email:

$mail->setFrom('Bob, b');

The smtp added {root@mysmtpblabla.example.com}

Can PHPMailer handler such a case? sending with name only?

  • 写回答

1条回答 默认 最新

  • doushi7761 2017-02-09 17:55
    关注

    It really helps to actually read the docs for the function you're calling.

    Applying that info to your example, you should do this:

    $mail->setFrom("b@example.com", "Bob, b");
    

    In most email clients it will display the name and not the email - in Outlook or Apple Mail it will usually show you the email address next to the name or on rollover - just because it doesn't display the address doesn't mean that there isn't one!

    Some email services will not let you send from arbitrary addresses (such as gmail), so you may still find the from address itself changes.

    You should not try to send without a from address for all the reasons Michael_B gave, plus that it's also very unlikely to work at all; that's why both PHP and PHPMailer add one that's generated automatically from your hostname.

    评论

报告相同问题?

悬赏问题

  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线