Skip to content

Instantly share code, notes, and snippets.

Created November 23, 2013 05:32
What would you like to do?
Using PHP Mailer to Send HTML Emails with Images
$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";
Copy link

Very good!
Thanks for all.

Copy link

bozdoz commented May 8, 2020

Couldn't get the official docs examples to work, but this works great (minus AddEmbeddedImage -> addEmbeddedImage).


Copy link

sebesh commented Mar 2, 2021


Copy link

OMG!! Thx!! Worked for me! :)

Copy link

it was showing download icon . i want only image in this not download options for images

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment