SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2009
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Image not shown in mail

    [B]The following code i used to send mail.it works fine But image not shown in the mail and also i looking that image wants to display while open the mail dont want click 'show image'.
    Could any one tell solution.

    <?php
    $eid=$_POST['ceid'];

    require("class.phpmailer.php");
    $mail = new PHPMailer();
    $mail->IsMail();
    $mail->From = "noreply@timezoneguide.com";
    $mail->AddAddress("$eid");
    $mail->Subject = "Results";
    $mail->IsHTML(true);
    $mail->AddEmbeddedImage('m2.jpg','mailimage','m2.jpg');
    $mail->Body="Hi! \n\n This is my first e-mail sent through PHPMailer<table style='border: thin solid #4682B4; border-collapse: collapse;' align='center'><tr><td><img src='cid:mailimage'></td></tr></table>";

    if(!$mail->Send())
    {
    echo 'Message was not sent.';
    echo 'Mailer error: ' . $mail->ErrorInfo;
    } else
    {
    echo 'Message sent';

    }
    ?>

  2. #2
    SitePoint Guru deepM's Avatar
    Join Date
    Dec 2007
    Location
    India
    Posts
    705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello Ravindran,

    i was searching for related this topic. but i think we can not send images through mails.

    check this link

    http://stackoverflow.com/questions/1...-an-html-email


    if anyone knows how to send images thorugh mails,would like to know that.


  3. #3
    SitePoint Guru deepM's Avatar
    Join Date
    Dec 2007
    Location
    India
    Posts
    705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I got something related this.

    try this

    PHP Code:
    $htmlBody '<html>
    <head>
    <title>My HTML Email</title>
    </head>
    <body>
    <img src="http://www.phpfreaks.com/images/phpfreaks_logo.jpg" alt="PHP Freaks" /><br />
    <h2>PHP Freaks Rules!</h2>
    <p>We invite you to visit <a href="http://www.phpfreaks.com" title="PHP Freaks">PHP Freaks.com</a> for a loving community of PHP Developers who enjoy helping each other learn the language!</p>
     
    <p>Sincerely,<br />
    PHP Freaks Staff</p>'
    ;
     
    $mailer->Body($htmlBody);
    $mailer->isHTML(true);
     
    // Send the E-Mail 

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,608
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    There are two ways to put images in emails.

    1. Place the images on the web and link to them from the email. This is what spammers do with transparent images to capture email addresses so sensible people have that option turned off.
    2. Embed the image in the email itself. To do this you need code in the script generating the email that will take the image in its ofiginal format and convert it to how it needs to be to embed it in the email. Presumably that is what the $mail->AddEmbeddedImage('m2.jpg','mailimage','m2.jpg'); line is calling with that particular script.

    The most likely reason it wouldn't be working is if you have the parameters in the call incorrect. The other possibility that occurs to me is that despite its name it may only be linking to the image and your email program probably has that blocked.

    I am not familiar enough with that particular email script to know which of those two is the right answer.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  5. #5
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,608
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by deepson2 View Post
    <img src="http://www.phpfreaks.com/images/phpfreaks_logo.jpg" alt="PHP Freaks" />
    That's linking to the image and not embedding it so few people will actually see the image. Also that way requires uploading the image to the web whereas embedding the image doesn't.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  6. #6
    SitePoint Guru deepM's Avatar
    Join Date
    Dec 2007
    Location
    India
    Posts
    705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good description felgall.

    But i have never seen any image yet which opens into mail body.

    Do you think that we can actually put image into mail body?

    I will try my second code and ll let you know what happens.

  7. #7
    SitePoint Enthusiast
    Join Date
    Oct 2009
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use this code It works..
    $mail->AddEmbeddedImage("m2.jpg","mailimage","m2.jpg","base64","image/jpg");


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •