PHP邮件功能将x-msg添加到所有链接......?

时间:2012-06-14 12:46:40

标签: php email

邮件很好但链接看起来像这样: x-msg://63/'www.something.com/'

$from_user = $_POST["fromuser"];
$subject = $_POST["subject"];

$headers = "From: $from_user <{$_POST['fromemail']}>\r\n". 
               "MIME-Version: 1.0" . "\r\n" . 
               "Content-type: text/html; charset=UTF-8" . "\r\n" .  "X-Mailer: PHP/" . phpversion();

     if(mail($_POST["toemail"], $_POST["subject"], wordwrap(urldecode($_POST["ebody"]),70), $headers)){
     ...
     }

与服务器有关吗?

身体的代码:

$this->ebody = "<html><head><title>" . $this->subject . "</title></head><body>
<img src='$imageurl' height='65px'><p><strong>AUTOMATED ORDER FORM.</strong>

</p>Please do not reply this message.<p>" . $body . "</p><hr>All Rights Reserved.<br><a href='http://www.something.com'>Company Name.</a></body></html>";

生成的电子邮件(原始来源):

> To: ###@gmail.com Subject: New Order - 14/06/12 MIME-Version: 1.0
> Content-type: text/html; charset=utf-8 X-Priority: 3 X-Mailer:
> PHP5.2.9 From: KSONE <noreply.ksone@something.com> Reply-To: Sales
> <sales@something.com>
> 
> 
> <html><head><title></title></head><body><img
> src=\"http://www.something.com/imgs/logo.png\"
> height=\'65px\'><p><strong>AUTOMATED VENDOR ORDER
> FORM.</strong></p>Please do not reply this message 027777777<p>Hello
> World!</p><hr>1/76 All Rights Reserved 12120.<br><a
> href=\'http://www.something.com\'>Company Co., Ltd.</a></body></html>

2 个答案:

答案 0 :(得分:8)

AFAIK x-msg://是Mail.app预先添加到没有有效方案的所有链接的占位符方案。换句话说,您的链接可能看起来像://foo/bar或类似的东西,在这种情况下,Mail.app会插入x-msg来制作完整有效的URI。

修复应用中的链接,以发送完整有效的网址。

答案 1 :(得分:1)

已解决:这是因为我在问题中遗漏了一些东西。我在启用远程邮件的服务器上创建了一个API,本地脚本通过CURLs发出POST请求。认为CURLs请求很顺利,输出电子邮件被错误地转义。这是因为我没有对我的POST变量执行urlencode,导致发生了疯狂的事情。