Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 656
  • Last Modified:

Problem sending mail with .php - Error with <IMG

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
<?
session_start();
$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);
print_r($addresses);
$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>
<head>
<BODY>
<IMG src="http://www.xxx.com/logo_tagline_small.gif" 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";
}else{
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

0
KingSencat
Asked:
KingSencat
1 Solution
 
quincydudeCommented:
change

$msg = "<html>
<head>
<BODY>
<IMG src="http://www.xxx.com/logo_tagline_small.gif" id=IMG1></BODY></HTML>";

to



$msg = <<<HTMLCONTENT
<HTML>
<HEAD>
</HEAD>
<BODY>
<IMG src="http://www.xxx.com/logo_tagline_small.gif" id="IMG1"></BODY></HTML>
HTMLCONTENT;

Open in new window

0
 
aherpsCommented:
You need to comment out your quotations:



<IMG src=\"http://www.xxx.com/logo_tagline_small.gif\" id=IMG1></BODY></HTML>";

Open in new window

0
 
Loganathan NatarajanLAMP DeveloperCommented:
you also try with single quote

$msg = "<html>
<head>
<BODY>
<IMG src='http://www.xxx.com/logo_tagline_small.gif' id='IMG1'/></BODY></HTML>";

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now