dongyun3805 2013-11-24 22:10 采纳率: 0%
浏览 79
已采纳

用垃圾字符解析地址的电子邮件

I'm sending e-mails through a form I coded and for some reason, for some cases the e-mail address becomes junk, and for other times it works fine.

//on form page
$message = str_replace("@e",$emtemail,$message);

$message is stored in SQL (defined on another page), same for $emtemail. $message is just the body of the e-mail being sent, and I'm replacing all instances of @e with the e-mail people send payments to. It sends one e-mail to the customer, and one e-mail to me.

//customer e-mail
//the display address might appear as payment52.62gmail.com instead of payment@gmail.com
//my e-mail
//all e-mail addresses formatted properly without error, @ appears as @

Why do e-mail addresses parse strangely? Something to do with encoding?

This is all of the code relevant to sending e-mails I have. I can't pinpoint the problem.

//any variables used in the below but not declared are previously initialized
$em = $userc["email"];
$subject = $emailone["subject"];
$subject = str_replace("@o",$ordernum,$subject);
$subject = str_replace("@u",htmlspecialchars($rn),$subject);
$subject = str_replace("@g",$gt,$subject);
$subject = str_replace("@sl","www.SZVapor.com",$subject);
$subject = str_replace("@ss","SZVapor.com",$subject);
$subject = str_replace("@st","SZVapor",$subject);
$message = nl2br($emailone["message"]);
$message = str_replace("@o",$ordernum,$message);
$message = str_replace("@u",htmlspecialchars($rn),$message);
$message = str_replace("@t",$table,$message);
$message = str_replace("@e",$emtemail,$message);
$message = str_replace("@g",$gt,$message);
$message = str_replace("@a",$addrsubmit,$message);
$message = str_replace("@sl","www.SZVapor.com",$message);
$message = str_replace("@ss","SZVapor.com",$message);
$message = str_replace("@st","SZVapor",$message);
$message = str_replace("@c",$em,$message);
$headers = "MIME-Version: 1.0"."
";
$headers .= "Content-type: text/html; charset=iso-8859-1"."
";
$headers .= "From: no-reply@SZVapor.com";
mail($em, $subject, $message, $headers);

Some examples of e-mail addresses given:

payment62.44gmail.com
payment54.45gmail.com
payment22.59gmail.com
payment25.49gmail.com
  • 写回答

2条回答 默认 最新

  • douba1904 2013-11-24 22:22
    关注

    http://php.net/manual/en/function.mail.php

    The first parameter entry for mail is the email address.

    The code above does not do anything with $em

    And by the way, I think that the last header line should look like this:

    $headers .= "From: no-reply@SZVapor.com" . "
    ";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料