Email Inline Images

Discussion in 'PHP' started by baddot, Dec 17, 2006.

  1. #1
    Hi i have made a script which i need to send to send to my list of database over 300 000 emails. But when i send over to the mail for testing, and when i recieved the mail i need to right click on my picture to press download from my windows outlook to view the picture. can i know how to make it to the way when i send to my customers it will auto show the pictures out like those spam virgra pictures to my mails ?

    
    $query = mysql_query("SELECT * FROM VB_Email where SENT = 0");
    while($r=mysql_fetch_row($query){
    $tosend = $r[1];
    $headers = "From: webserver@localhost\r\n";
    
    $headers .= "MIME-Version: 1.0\r\n";
    $theFile = "dreamchat.jpg";
    $content_encode = chunk_split(base64_encode($theFile));
    $boundary = '-----=' . md5( uniqid ( rand() ) );
    $headers .= "Content-Type: multipart/mixed; boundary = $boundary\r\n\r\n";
    $message .= "Content-Disposition: inline; filename=\"$theFile\"\n\n";
    
    $body = "--$boundary\r\n" .
       "Content-Type: text/plain; charset=ISO-8859-1\r\n" .
       "Content-Transfer-Encoding: base64\r\n\r\n";
    $body .= chunk_split(base64_encode("This is the plain text version!"));
    
    $body .= "--$boundary\r\n" .
       "Content-Type: text/html; charset=ISO-8859-1\r\n" .
       "Content-Transfer-Encoding: base64\r\n\r\n" . "Content-Disposition: inline; filename=\"$theFile\"\n\n".
       "Content-Disposition: attachment; filename=\"$theFile\"\n\n";
    $body .= chunk_split(base64_encode(" This the <b>Dreamchat.sg</b> <img src='$content_encode'> version!"));
    
    mail($tosend, "An HTML Message", $body, $headers);
    }
    
    PHP:

     
    baddot, Dec 17, 2006 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Don't assign the variables which are always the same in your loop 300.000 times over and over again. Then I'd recommend to send first 100 mails, wait a while, and then send the next 100. If you send 300.000 continuously you will get your DNS blocked by most recipient hosts as they'd consider you as a spammer. I'd also use PHPMailer to send your mails. And you can send the mails as HTML and insert the image.
     
    nico_swd, Dec 18, 2006 IP
  3. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #3
    pictures are blocked by outlook by default, no way to change that......not from a script anyways......
     
    krakjoe, Dec 18, 2006 IP
  4. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You cannot be guaranteed that images will be automatically shown when people view your email. One of the most important strategies for seeing spam is to ONLY view email as plain text.

    Some companies forbid employees to view email in any other way and that habit has carried over into their personal lives. There is a debate within my company over whether to strip all pictures attached to emails as soon as they reach our primary mail server.

    Solving your problem requires that the message be formatted as if it were a web page. You will call the inline message from within the email. When I have time, I will be creating such an email message, except that the image will reside on our server and email client's will either auto download the image, or people will click on the link. To maximize clicking, we will make the image something uniquely useful to the target audience. In my application, it will be a graph representing key data in an article sent to a subscribers on a list that they pay to join.
     
    clancey, Dec 18, 2006 IP
  5. baddot

    baddot Active Member

    Messages:
    309
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    58
    #5
    as for the php mailer i tried but i don't know how do i input the mysql into the class function
     
    baddot, Dec 19, 2006 IP
  6. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #6
    Do it the other way. Put the class into the while() loop.

    
    
    include('class.phpmailer.php');
    
    $mail = new PHPMailer();
    $mail->isSMTP();
    $mail->FromName = 'Your company name or whatever';
    $mail->Host = 'your-host.com';
    $mail->From = 'info@your-host.com';
    $mail->Subject ='Subject goes here';
    $mail->WordWrap = 80;
    $mail->Body = 'Your body content';
    
    while($r=mysql_fetch_row($query))
    {
       $mail->AddAddress($r['email']);
    }
    
    $mail->Send();
    
    
    PHP:

    http://phpmailer.sourceforge.net/tutorial.html
     
    nico_swd, Dec 19, 2006 IP
  7. baddot

    baddot Active Member

    Messages:
    309
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    58
    #7
    wao ill give it a try thank you
     
    baddot, Dec 19, 2006 IP
  8. gpradeepjain

    gpradeepjain Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    hii guys small prob related to images inline..i have stored the image in database in form of blob and now i want to send the picture inline in a mail how to do it...
     
    gpradeepjain, Jul 28, 2008 IP
  9. e2developer

    e2developer Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Hi all,

    Please suggest me a way so that i can send images in mail as inline attachment because i think this is only way by which i can show images in mail without asking for an option to download the images.

    Thank you
    Dheerendra
     
    e2developer, Jul 29, 2009 IP