如何使用wp_mail()在邮件头中显示图像

时间:2016-08-17 18:08:25

标签: php wordpress image email html-email

如何在电子邮件标题中显示图像。我在下面试过,它在gmail中没有显示图像。请任何人帮我解决这个问题。

    $to = $_REQUEST['userEmail'];
    $firstName = $_REQUEST['firstName'];
    $lastName = $_REQUEST['lastName'];
    $email = $_REQUEST['email'];
    $question = $_POST['message'];
    $subject = 'Test Email';
    $message = "<html><head><img src='http://192.168.1.157/Shop/wp-content/uploads/2016/07/image_nmae.png'/></head>"
            . "<body><h1>Visitor Information</h1>"
            . "<p>Visitor Information: Fist Name:&nbsp;&nbsp;".$firstName."&nbsp;&nbsp; Last Name:&nbsp;&nbsp; ".$lastName."</p>"
            . "<p>Email:&nbsp;&nbsp;".$email."</p><p>Question:&nbsp;&nbsp;".$question."</p></body></html>";
    $headers = array('Content-Type: text/html; charset=UTF-8');
    $mailSend = wp_mail($to, $subject, $message,$headers);

1 个答案:

答案 0 :(得分:0)

这取决于用户Gmail帐户settings,就像在我的Gmail帐户中我关闭了图片呈现一样,它是否允许我加载它们。

/page.php标记移到<img>标记内,在头标记内显示图像不是一个好习惯。

如果它不起作用,请将其写在<body>文件中。

functions.php