php邮件在尝试发送单词“”时中断;localhost”;在电子邮件正文中-太奇怪了


php mail breaks when trying to send the word "localhost" in email body - so weird

我有一个php邮件表单,买家填写该表单可以向卖家发送电子邮件。一切都很好,只是我正在本地主机MAMP服务器上测试它。

问题:$message1(电子邮件正文)来自$_POST['textarea']。如果有url"http://localhost"通过表单文本区域(放在电子邮件正文中)发送,然后当电子邮件永远不会发送。http://www.anythingelse.com工作良好。。。。我很困惑。是否有一些安全功能可以禁用通过表单发送的本地主机URL?

如果我的代码中还有其他明显的错误,我们将不胜感激。

谨致问候,Daniel

public function saleRequest($seller_email, $seller_username, $buyer_email, $buyer_username, $book_title, $subject1, $message1) {

    define("NAME","xxxxxxx");
    define("FROM",$buyer_email);
    $subject = substr_replace($subject1, '', 30);
    // -=-=-=-=- MAIL HEADERS
    $mime_boundary = md5(time()); 
    $headers = "From: ".NAME." <".FROM.">'n";
    $headers .= "MIME-Version: 1.0'n"; 
    $headers .= "Content-Type: multipart/alternative; boundary='"$mime_boundary'";'n'n"; 
    // -=-=-=-=- TEXT EMAIL PART
    $message = "--$mime_boundary'n";
    $message .= "Content-Type: text/plain; charset=UTF-8'n"; 
    $message .= "Content-Transfer-Encoding: 8bit'n'n"; 
    $message .= wordwrap(stripslashes($message1), 30, PHP_EOL)."'n";
    // -=-=-=-=- HTML EMAIL PART
    $message .= "--$mime_boundary'n"; 
    $message .= "Content-Type: text/html; charset=UTF-8'n"; 
    $message .= "Content-Transfer-Encoding: 8bit'n'n"; 
    $message1 = $message1."this is html";
    $message .= nl2br(wordwrap(stripslashes($message1), 30, "<br>"))."<br>'n";
    // -=-=-=-=- FINAL BOUNDARY
    $message .= "--$mime_boundary--'n'n";
    unset($mime_boundary);
    return mail($seller_email,$subject,$message,$headers);
}

听起来像垃圾邮件过滤器。对于大多数SMTP服务器来说,过滤掉包含localhost URL的邮件是有意义的。

检查其中一条工作消息的标头。查看它通过了哪些服务器(Received行),并询问这些服务器的系统管理员,或者更好:将邮件服务器配置为本地发送所有测试邮件,而不是通过任何第三方发送。这样你就可以控制环境。如果您已经控制了所有涉及的邮件服务器,请检查它们的日志文件。

是否有一些安全功能可以禁用通过表单发送的本地主机URL?

没有至少在PHP中没有。可能是邮件服务器问题,但这需要与每个MTA进行检查。