doudou1897 2012-03-16 18:38
浏览 59


I have a mail function with the standard parameters:

mail($to, $subject, $message, $headers);


$headers = "From:";
$headers .= "
Content-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\""; 

Now, I'm trying to get the sent e-mails to show 'My Site' as the sender instead of '' but if someone responds to the mail it still needs to go to

I've tried putting "My Site" in the "From" field before and after the e-mail address but it just appends to the address. I've tried appending it to the $headers variable but that messes the whole e-mail up. I've also tried adding it this way:

$headers .= "
My Site";

but that doesn't seem to do anything.

I know this can't be complicated as I've seen it done a hundred times, but I can't seem to find a straight-forward answer for this - how do I 'mask' the admin e-mail with the site name but still keep it as the address any response goes to?

  • 写回答

2条回答 默认 最新

  • duancashi1362 2012-03-16 18:43

    Change your From: header to "From: My Site <>"

    $headers = "From: My Site <>";
    $headers .= "
    Content-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"";

    From the PHP Docs.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥15 帮我解决一下膳食平衡的线性规划模型的数据实例
  • ¥40 万年历缺少农历,需要和阳历同时显示
  • ¥250 雷电模拟器内存穿透、寻基址和特征码的教学
  • ¥200 比特币ord程序wallet_constructor.rs文件支持一次性铸造1000个代币,并将它们分配到40个UTXO上(每个UTXO上分配25个代币),并设置找零地址
  • ¥15 关于Java的学习问题
  • ¥15 如何使用chatgpt完成文本分类任务?
  • ¥15 已知速度v关于位置s的等式,怎么转化为已知位置求速度v的等式
  • ¥15 我有个餐饮系统,用wampserver把环境配置好了,但是后端的网页却进去,是为什么,能不能帮远程一下?
  • ¥15 R运行没有名称为"species"的插槽对于此对象类"SDMmodelCV"
  • ¥20 基于决策树的数字信号处理,2ask 2psk 2fsk的代码,检查下报错的原因