Problem sending mail with .php - Error with <IMG

Posted on 2008-11-12
Last Modified: 2012-06-21
I am trying to send an .html email with .php and i get error if i use IMG, Look at my attached code below and tell me what i am doing wrong.

Thank you


$batch = 1; //<== Put the number of addresses to which you want to send at one time here

$wait = 1; //<== Put the number of seconds to wait between batches here

$file = 'Emails.txt'; //<== Put the real path to the Emails.txt file here

$addresses = file($file);


$num = count($addresses);

$headers  = 'MIME-Version: 1.0' . "\r\n";

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$headers .= 'From: xxl! <no-reply@xx>' . "\r\n";

$subj = "lalala" ;

$msg = "<html>



<IMG src="" id=IMG1></BODY></HTML>";

$i = 1;

$to = ''; //<== initialize an empty $to

while ($i <= $num) {

echo "<p>$i</p>\n";

            if(!empty($addresses[$i])) $to .= rtrim($addresses[$i]) . ", ";


            if($i % $batch == 0){ //If the $i is equally divisible by $batch, it's time to send the mail and sleep

                  $to = substr($to,0,strlen($to)-2); //Strip off the trailing comma and space

              if(mail($to, $subj, $msg, $headers)){

echo "<p>Sent mail to $to.</p>\n";


echo "<p>Failure sending mail to $to.</p>\n";


              sleep($wait); //tell the script to wait before continuing

              $to = ''; //reset $to, starts address list over, doesn't mail people twice

        } // end if


        $i++; //increment $i to get the next address from the array


} // end while

header("Location: emails_send.html");


Open in new window

Question by:KingSencat
    LVL 15

    Expert Comment


    $msg = "<html>
    <IMG src="" id=IMG1></BODY></HTML>";


    $msg = <<<HTMLCONTENT
    <IMG src="" id="IMG1"></BODY></HTML>

    Open in new window

    LVL 7

    Accepted Solution

    You need to comment out your quotations:

    <IMG src=\"\" id=IMG1></BODY></HTML>";

    Open in new window

    LVL 36

    Expert Comment

    by:Loganathan Natarajan
    you also try with single quote

    $msg = "<html>
    <IMG src='' id='IMG1'/></BODY></HTML>";

    Open in new window


    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
    I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now