Reputation: 3368
I am trying to add my companies logo inside of a php email that I will be sending out to customers after they order. However, it is not working. The actual link to my image is a public url.
What am I doing wrong?
$logoImage = 'https://example.com/images/BFBlogo1.gif';
// Prepare the Email
$to = $email;
$subject = 'Your Example order'. $AuthorrizeResponseText; transaction Id or invoice #, however you set it up as.
$message = '<img src="'.$logoImage.'">';
$message = 'Thank you for ordering with us! ';
$from = "[email protected]";
$cc = "[email protected]";
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: ' .$to. "\r\n";
$headers .= 'From: ' .$from. "\r\n";
$headers .= 'Cc: '.$cc. "\r\n";
// Send the email
mail($to,$subject,$message,$headers);
My second attempt:
$message = '<img src="'.$logoImage.'">';
$message .= 'Thank you for ordering with us! ';
Upvotes: 1
Views: 900
Reputation: 9351
You forgot to concate:
$message = '<img src="'.$logoImage.'">';
$message = 'Thank you for ordering with us! '; // here $message is overwrtting.
Should be like this:
$message = '<img src="'.$logoImage.'">';
$message .= 'Thank you for ordering with us! ';
Update
logoImage = 'https://example.com/images/BFBlogo1.gif';
// Prepare the Email
$to = $email;
$subject = 'Your Example order'. $AuthorrizeResponseText;
$message = '<img src="'.$logoImage.'">';
$message .= 'Thank you for ordering with us! ';
$from = "[email protected]";
$cc = "[email protected]";
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: ' .$to. "\r\n";
$headers .= 'From: ' .$from. "\r\n";
$headers .= 'Cc: '.$cc. "\r\n";
// Send the email
mail($to,$subject,$message,$headers);
Upvotes: 2
Reputation: 218877
You set the image tag:
$message = '<img src="'.$logoImage.'">';
But then on the very next line you overwrite it:
$message = 'Thank you for ordering with us! ';
Maybe you meant to concatenate instead?:
$message .= 'Thank you for ordering with us! ';
Please note also that if nearly the entire body of the message is an image then I wouldn't be at all surprised if the mail is treated as spam by almost any system that looks at it.
Upvotes: 0