电子邮件标题“格式错误”当使用 php 中的 sendmail 命令时。为什么?

发布于 2025-01-07 11:50:04 字数 1501 浏览 0 评论 0原文

我在使用 sendmail 命令时遇到问题。

我正在从数据库调用中提取值,它们看起来不错。 邮件命令如下所示:

sendmail(urldecode($row['tracker']),urldecode($row['recipient']),urldecode($row['docurl']),urldecode($row['last_accessed']));

function sendmail($vtracker,$vrecip,$vrawurl,$viewed){
    $to = $vtracker;
    $subject = $vrecip . " has viewed the presentation you sent them.</br>";
    $body= "Full document url:  " . $vrawurl . "<br/>".
    "Time and Date Viewed:  :" .$viewed ;

    if (!mail($to, $subject, $body)) {
       echo("<p>Message delivery failed...</p>");
    }
}

我回显了所有变量,它们看起来正常:

$vtracker:  Bob ;
$vrecip : [email protected] ;
$vrawurl : https://docs.google.com/a/advetel.com/present/edit?id=0Ac_KwUsBMiw8ZGN2Z3N3cDlfMTc3c2Jubng0Z2Q ;
$viewed : Mon, 20 Feb 2012 10:36:22 CST ;

我收到一个如下所示的错误(从服务器上的错误日志中检索)。

[error] [client 66.249.68.23] File does not exist: /var/chroot/home/content/m/3/s/m3sglobal/html/broadband/missing.html
[Tue Feb 21 20:17:15 2012] [error] [client 70.113.8.83] Failed loading /usr/local/zo/4_3/ZendOptimizer.so:  /usr/local/zo/4_3/ZendOptimizer.so: undefined symbol: empty_string
[Tue Feb 21 20:17:17 2012] [error] [client 70.113.8.83] malformed header from script. Bad header=/home/content/m/3/s/m3sglobal/: Nitrofill_Presentation.php

为什么标题“格式错误”?

I'm having trouble with a sendmail command.

I'm pulling the values out of a database call, and they look good.
The mail command looks like this:

sendmail(urldecode($row['tracker']),urldecode($row['recipient']),urldecode($row['docurl']),urldecode($row['last_accessed']));

function sendmail($vtracker,$vrecip,$vrawurl,$viewed){
    $to = $vtracker;
    $subject = $vrecip . " has viewed the presentation you sent them.</br>";
    $body= "Full document url:  " . $vrawurl . "<br/>".
    "Time and Date Viewed:  :" .$viewed ;

    if (!mail($to, $subject, $body)) {
       echo("<p>Message delivery failed...</p>");
    }
}

I echoed all the variables and they look ok:

$vtracker:  Bob ;
$vrecip : [email protected] ;
$vrawurl : https://docs.google.com/a/advetel.com/present/edit?id=0Ac_KwUsBMiw8ZGN2Z3N3cDlfMTc3c2Jubng0Z2Q ;
$viewed : Mon, 20 Feb 2012 10:36:22 CST ;

I'm getting an error (retrieved from the error log on the server) that looks like this.

[error] [client 66.249.68.23] File does not exist: /var/chroot/home/content/m/3/s/m3sglobal/html/broadband/missing.html
[Tue Feb 21 20:17:15 2012] [error] [client 70.113.8.83] Failed loading /usr/local/zo/4_3/ZendOptimizer.so:  /usr/local/zo/4_3/ZendOptimizer.so: undefined symbol: empty_string
[Tue Feb 21 20:17:17 2012] [error] [client 70.113.8.83] malformed header from script. Bad header=/home/content/m/3/s/m3sglobal/: Nitrofill_Presentation.php

Why is the header "malformed"?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

假面具 2025-01-14 11:50:04

我认为多花点时间研究 RFC 2822 也没什么坏处。

您的 to 字段由 Bob 填充。这不是一个合法地址。有效电子邮件地址的格式相当复杂,但如今,地址通常采用 localpart@domain 形式。 (旧格式允许通过 % 用户名说明符或! bang-paths 通常不受支持;username@[] 在不同的服务器或配置上可能受支持,也可能不受支持。必须是一个@ 在电子邮件地址中,以将本地部分与域分开。)

您似乎还在使用用户提供的数据,但未确认其未执行标头注入攻击。 (另请参阅 suhosin 项目有关 suhosin.mail 的文档。保护。)

您的 subject 字段包含
,这是毫无意义的,因为 Subject: 标题被解释为纯文本。该字段似乎也使用数据库提供的原始数据。

邮件正文还包含
,这是毫无意义的,因为您的邮件不包含任何 MIME 标记,指示 text/html 内容

I think it wouldn't hurt to spend a bit more time with RFC 2822.

Your to field is populated with Bob. That it not a legal address. The format of valid email addresses is quite complicated but these days, addresses generally are of the form localpart@domain. (Older formats that allowed delivery to UUCP addresses via % username specifiers or ! bang-paths are often not supported; further, username@[<ip address>] may or may not be supported on different servers or configurations. In general, there must be an @ in an email address to separate the local part from the domain.)

You also appear to be using user-supplied data without any confirmation that it isn't performing header injection attacks. (See also the suhosin project's documentation about suhosin.mail.protect.)

Your subject field includes a </br>, which is pointless, since the Subject: header is interpreted as plain text. This field also appears to be using raw data supplied by the database.

The message body also includes the </br>, which is pointless, since your message does not include any MIME markup to indicate the presence of text/html content.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文