图像不是嵌入在php中的电子邮件中

时间:2016-12-19 08:06:23

标签: php html-email

我正在尝试将图像嵌入到php中的电子邮件的html内容中,但无论何时发送的电子邮件都会显示我的图像链接。图片没有嵌入电子邮件这里是代码

<?php
$to = 'xxxx@xxxx.com';
$subject = "Beautiful HTML Email using PHP by CodexWorld";

$htmlContent = '
    <html>
    <head>
        <title>Welcome to CodexWorld</title>
    </head>
    <body>
        <h1>Thanks you for joining with us!</h1>
        <table cellspacing="0" style="border: 2px dashed #FB4314; width: 300px; height: 200px;">
            <tr>
                <th>Name:</th><td>CodexWorld</td>
            </tr>
            <tr style="background-color: #e0e0e0;">
                <th>Email:</th><td>contact@codexworld.com</td>
            </tr>
            <tr>
                <th>Website:</th><td><a href="http://www.codexworld.com">www.codexworld.com</a></td>
            </tr>
              <tr>
                <th>image:</th><td><img src="http://xxxxxxxxxxxxx.com/email/1.png"/></td>
            </tr>
        </table>
    </body>
    </html>';

// Set content-type header for sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

// Additional headers
$headers .= 'From: xxxx@xxxxx.com' . "\r\n"; 

// Send email
if(mail($to,$subject,$htmlContent,$headers)):
    $successMsg = 'Email has sent successfully.';
else:
    $errorMsg = 'Email sending fail.';
endif;
?>

请指导我哪里错了

0 个答案:

没有答案