在PHP邮件功能中显示图像


Displaying image in PHP mail function

我正在尝试在 PHP mail()函数中添加图像,但由于某种原因,它没有显示图像。

if ($_SESSION["code"] == $captcha) {
    $to = $email;
    $subject = 'Details';
    $message = '<image/logo" alt="Website logo" />';
    $message .= '<p>Hi ' . $fname . ', We are xyz xyz xyz n ' . $date . 
                '. <br> We have you booked in for ' . $noofguests . ' people.</p>
                <p>If you have any questions or special requests please fees or special requests please fees or special requests please feel free to <a href="http://google.com">us</a>.</p>
                <p>Thank you.</p>
                ';
    $headers = "MIME-Version: 1.0" . "'r'n";
    $headers .= "Content-type:text/html;charset=iso-8859-1" . "'r'n";

更改此设置。

$message = '<image/logo" alt="Website logo" />';

对于这样的东西..

$message = '<img src="http://www.yourwebsite.com/yourlogo.png" alt="Website logo" />'; // Replace the src with your actual URL to the file

将 src 替换为实际徽标图像的 URL。 不管那是什么。

<image/logo 标签不存在。

$message = '<image/logo" alt="Website logo" />';

您需要使用<img src标记:

$message = '<img src="http://example.com/logo.png" alt="Website logo" />';
  • example.com更改为您的实际网站。

此外,logo.png不会显示在实际的电子邮件中;您需要一个绝对路径,例如 http://example.com/logo.png .