Php 未发送带有img标记的Html电子邮件

Php 未发送带有img标记的Html电子邮件,php,html,Php,Html,我有一个奇怪的问题,当我发送一封没有标记的html电子邮件时,电子邮件会被发送出去,但是如果包含标记,则不会发送任何电子邮件。以下是我正在使用的html以及用于发送电子邮件的php代码: HTML: PHP代码: $from = "myemail@gmail.com"; $subject = "Some Subject"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charse

我有一个奇怪的问题,当我发送一封没有标记的html电子邮件时,电子邮件会被发送出去,但是如果包含标记,则不会发送任何电子邮件。以下是我正在使用的html以及用于发送电子邮件的php代码:

HTML:


PHP代码:

$from = "myemail@gmail.com";
$subject = "Some Subject";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Test <'. $from .'>' . "\r\n";

// get emailcontent.html content
$emailcontent = file_get_contents('emailcontent.html');

// send the actual message
$extraHeaders = 'To: ' . $name . ' <'. $to .'>' . "\r\n";
mail($to, $subject, $emailcontent, $headers . $extraHeaders);
$from=”myemail@gmail.com";
$subject=“某个主题”;
$headers='MIME版本:1.0'。“\r\n”;
$headers.='内容类型:文本/html;字符集=iso-8859-1'。“\r\n”;
$headers.='From:Test'。“\r\n”;
//获取emailcontent.html内容
$emailcontent=file_get_contents('emailcontent.html');
//发送实际消息
$extraHeaders='到:'$名字。“\r\n”;
邮件($to、$subject、$emailcontent、$headers.$extraHeaders);

尝试直接在
$emailcontent
中写入内容,而不使用
文件获取内容

同时检查邮件是否不在
垃圾邮件或垃圾邮件文件夹中
,如果是,则使用
标题中的
返回路径


另请阅读

如果您愿意发送带有html的电子邮件,则可以尝试以下方法:/

$image= '
<html>
<body>
  <img src="http://www.example.com/image/images.jpg">
</body>
</html>
';
您的
$headers
将内容类型设置为
text\html
。如果没有它,接收者会将您的消息视为纯文本。 作为:


考虑使用PHPMALLIER或SWIFTMAILER或类似的方式来发送HTML电子邮件,而不是手工编码PHP中的头文件。这让事情变得容易多了。
$image= '
<html>
<body>
  <img src="http://www.example.com/image/images.jpg">
</body>
</html>
';
mail("email@domain.com", "$subject", $image, $headers);
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";