0

How to display image in email header. I tried below, it in gmail it is not displaying the image. Please any one help me to resolve this. Thanks in advance.

    $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);
0

You can add your $headers before the form. Also parse $headers like this

$headers .= 
"Content-Type: text/html; 
charset=UTF-8\r\n";
| improve this answer | |
0

The email header is not the same as the <head> of an HTML document (even if that document is an email). So the question shouldn't be how to display an image in the email header because the answer is that you can't.

Second, the same thing holds true for an HTML document. The <head> section (where the <img> tag is currently located in the OP) is for holding information about the document, and what is contained in there will not be displayed.

Since the <img> tag in the <head> location will not be displayed, the problem is simply malformed HTML. To display, the <img> must be inside the <body> tag somewhere.

$to = $_REQUEST['userEmail'];
$firstName = $_REQUEST['firstName'];
$lastName = $_REQUEST['lastName'];
$email = $_REQUEST['email'];
$question = $_POST['message'];
$subject = 'Test Email';
$message = "<html><head></head><body><img src='http://192.168.1.157/Shop/wp-content/uploads/2016/07/image_nmae.png'/>"
        . "<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);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.