dsqnonh2763 2014-08-28 07:14
浏览 23
已采纳

PHP Mail功能:不会更改邮件中的显示名称

I'm currently working on an event registration form in which the user puts in his information and then the form sends it to us via PHPMail.

Everything is working fine, I receive all the inputs from the user, however, it seems that I can't change the display name of the sent mail.

My mailer code looks like this:

    $p_regist="registration<br /><br />";
    $p_receive="mymail@testmail.com";
    $p_sender="mymail@testmail.com";
    $p_subject="Registration".umw($_POST['f_name']).": ".$_POST['f_even'];
    $p_subject_user="Register Confirmation: ".$_POST['f_even'];
    $p_extra="from: $p_sender ";
    $headers .= 'From:Display Name here'."
";
    mail($p_receive, $p_subject, $p_mail_text, $p_mail_check, $p_extra, $headers)
        or print "Could not send mail to receiver";
    mail($_POST['f_mail'], $p_subject_kunde, $headers,
         'Thank you for your registration!',   $p_mail_text)
        or print "could not deliver mail";
    $p_sent=1;

I also tried sending the mail in a separate PHP file.

How can I include the submitter's full name in the email message 's headers?

  • 写回答

3条回答 默认 最新

  • druybew06513 2014-08-28 07:30
    关注

    You are putting in two From: headers but there can be only one.

    Probably remove $p_extra altogether and put the formatted sender header in the regular $headers.

    In addition, you need to audit your code for injection vulnerabilities. Basically, anything which comes from a POST will need to be vetted. In particular, make sure there are no newlines or other shenanigans in the input you are receiving from the user. For details, see e.g. PHP's mail(): What are potential issues to watch out for?

    You would probably be better off using a proper mail library; the basic functionality in PHP is ugly, insecure, and hard to use.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码