PHP电子邮件正在发送,但标题不是

时间:2022-10-23 17:22:11

I'm using several different mailers for a single website, because right now, none of them are working correctly. And they're all malfunctioning in the exact same way, ,so I don't believe that it's any of the mail functions, but I'd like another set of eyes on this to make sure I'm not missing something.

我在一个网站上使用了几个不同的邮件程序,因为现在,它们都没有正常工作。而且他们都以完全相同的方式发生故障,所以我不相信它是任何邮件功能,但我想要另外一套眼睛,以确保我不会错过任何东西。

Here's what's happening:

这是发生了什么:

The emails send just fine, but it looks like none of the header info I set is being used. When you get an email, the html is displaying as code, and the subject shows as part of the message.

电子邮件发送得很好,但看起来没有使用我设置的标题信息。当您收到电子邮件时,html显示为代码,主题显示为邮件的一部分。

Here's the header info:

这是标题信息:

$headers = "MIME-Version: 1.0" . $newLine;
$headers .= "Content-type: text/html; charset=iso-8859-1" . $newLine;
$headers .= "To: $nameto <$to>" . $newLine;
$headers .= "From: $namefrom <$from>" . $newLine

Here's the Send:

这是发送:

if ($test == true) {
    mail($to, $from, $subject, $message, $headers); 
    echo "<script>window.location = '/key-holders/index.php';</script>";
}

And here is what the email looks like:

这是电子邮件的样子:

<html><body><center><table bgcolor='#ededed' width='680px'><tr><td><img src='http://example.com/img/logo.png'  /></td></tr><tr><td><p>User Name has left you a special message on The Website.<br /> Please go to <a href='http://example.com/message/5493536206ab2'>http://example.com/message/5493536206ab2</a> to view your message.</p></td></tr></table></center></body></html>
    User Name Has a Special Message For You

Edit - Here's $newLine:

编辑 - 这是$ newLine:

    $newLine = "\r\n";

1 个解决方案

#1


0  

Remove $from parameter from mail function:

从邮件功能中删除$ from参数:

mail($to, $subject, $message, $headers);

Make sure, that $newLine = "\r\n";

确保$ newLine =“\ r \ n”;

#1


0  

Remove $from parameter from mail function:

从邮件功能中删除$ from参数:

mail($to, $subject, $message, $headers);

Make sure, that $newLine = "\r\n";

确保$ newLine =“\ r \ n”;