PhPmailier detect if inline image exist and how to embed if it is a copied from internet ?

Alex Lord
Alex Lord used Ask the Experts™
$mail = new PHPMailer();$mail = new PHPMailer();
$mail->Host = ";";
$mail->SMTPAuth = true;
$mail->Username = 'smtpusername';
$mail->Password = 'smtppassword';

$mail->FromName="My site's mailer";
$mail->AddReplyTo("", "Replies for my site");

$mail->Subject = "Test 1";

$mail->AddEmbeddedImage('logo.jpg', 'logoimg', 'logo.jpg'); // attach file logo.jpg, and later link to it using identfier logoimg
$mail->Body = "<h1>Test 1 of PHPMailer html</h1>
    <p>This is a test picture: <img src=\"cid:logoimg\" /></p>";
$mail->AltBody="This is text only alternative body.";

   echo "Error sending: " . $mail->ErrorInfo;;
   echo "Letter is sent";

Open in new window

im looking at this example,

how can i use this for inline images copied into the email body and how can i even tell if their is a img in the body ?

cause not all users will embed a image inline on email ?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2017
Distinguished Expert 2018

PHPMailer does have a function to add an embedded image you can read more about it here

The other option is to reference the image from a server resource in other words just put a link in for the img.
Most Valuable Expert 2017
Distinguished Expert 2018

Re-read your question - not sure what you are asking - the sample you posted already shows the use of addEmbeddedImage?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial