【问题标题】:Display images in email using mail() in PHP在 PHP 中使用 mail() 在电子邮件中显示图像
【发布时间】:2011-08-17 15:23:14
【问题描述】:

如何使用 PHP 中的mail() 函数在电子邮件中显示图像?

设置<img src="image path" /> 有效吗?

【问题讨论】:

标签: php image email


【解决方案1】:

尝试以 html 格式发送邮件。看这个 http://www.webcheatsheet.com/PHP/send_email_text_html_attachment.php

【讨论】:

    【解决方案2】:

    您需要设置标题以告诉它它是 HTML。你可以这样做:

    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    

    然后发送

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

    因此您将标头作为字符串传递给mail() 的第四个参数。

    您应该在charset 中设置相关的字符编码,如果要发送给最终用户,还应提供文本版本。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-20
      • 2013-04-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多