when i send email from php mial funtion it working best in yahoo and gmail acounts but images and background images is not showing in outlook 2007,tell me what is solution and better way to show image in oulook

<?php

// multiple recipients (note the commas)
$to = "zohaib@sikone.com, ";

// subject
$subject = "Eid Card";

// compose message
$message = '
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <title>Fillon soutient à fond le retour d\'un Grand Prix de France</title>
</head>
<body>
   <p>Le Premier ministre François Fillon, passionné d\'automobile et pilote à ses heures, a apporté un soutien appuyé au retour d\'un Grand Prix de France au calendrier 2013 de la Formule 1, en faisant un passage-éclair vendredi sur le circuit Paul Ricard dans le Var.</p>
    <img src="" width="500" height="498">
    <div style=" background-image:url(); width:100px; height:200px; font-size:16px;">
   <p>Le Premier ministre François Fillon, passionné d\'automobile et pilote à ses heures, a apporté un soutien appuyé au retour d\'un Grand Prix de France au calendrier 2013 de la Formule 1, en faisant un passage-éclair vendredi sur le circuit Paul Ricard dans le Var.</p> </div>
</body>
</html>
';

// To send HTML mail, the Content-type header must be set
    $headers  = "From: Eid Card<info@izhar.com>\r\n";
    $headers .= "Reply-To: info@izhar.com\r\n";
    $headers .= "Return-Path: info@eizhar.com\r\n";
    $headers .= "X-Mailer: Drupal\n";
    $headers .= 'MIME-Version: 1.0' . "\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
// send email
mail($to, $subject, $message, $headers);
?>

Dani AI

Generated

the behavior you see is mostly Outlook being Outlook. Two things bite here:

  1. Outlook blocks external images by default until the user clicks Download Pictures (what @Citytech.tester described). That is normal and configurable in Trust Center. See Microsoft’s guidance: Block or unblock automatic picture downloads in Outlook. (support.microsoft.com)
  2. Outlook 2007 uses the Word rendering engine, which does not support CSS background-image at all, so a styled div background will never show. This is by design in Word/Outlook 2007’s HTML/CSS support matrix. See Microsoft’s spec: Word 2007 HTML and CSS Rendering Capabilities in Outlook 2007. (learn.microsoft.com)

Workarounds that actually ship:

  • If an image must display without that Download Pictures click, embed it as an inline attachment (multipart/related) and reference it with a Content-ID. Libraries make this easy. Example with PHPMailer:
use PHPMailer\PHPMailer\PHPMailer;

$mail = new PHPMailer();
$mail->isHTML(true);
$mail->setFrom('info@example.com','Eid Card');
$mail->addAddress('zohaib@sikone.com');
$mail->Subject = 'Eid Card';
$mail->addEmbeddedImage('/path/to/01.jpg', 'eid1', '01.jpg');
$mail->Body = '<img src="cid:eid1" width="500" height="498" alt="Eid image">';
$mail->send();

Docs: PHPMailer addEmbeddedImage. (phpmailer.github.io)

  • For background images, either avoid them or use an Outlook-only VML fallback (the classic v:rect/v:fill trick). Microsoft’s forums acknowledge VML as the route for Outlook backgrounds: Layered VML for Outlook. (learn.microsoft.com)

Quick hygiene: make your charset consistent (your meta says UTF-8 but header says ISO-8859-1), and stick to table-based layout with inline styles for Outlook. This should get your card looking right in Outlook while keeping Yahoo/Gmail happy.

Outlook doesn't show images directly. Open your email in outlook, just after the subject there is a text starting with "If there are problems with how this message is displayed ....... " click on this text, a dropdown box will open with few links. Click on the first link called "Download Pictures".

Thats it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.