First, you need to send your newsletter in HTML format. You can then paste the image into your newsletter as
<img src="image_url">
image_url may be remote or inline. A remote image reduces email, but most email clients request user approval. The embedded image will be displayed without a user request, but it will be part of the email.
To use a remote image, just place the image somewhere and put the URL as image_url.
The embedded image must be encoded as part of the MIME. It is not so difficult. You need to use a package like PhpMailer,
http://sourceforge.net/projects/phpmailer/
Here is an example
<?php require("class.phpmailer-lite.php"); $mail = new PHPMailerLite(); $mail->From=" you@example.com "; $mail->FromName="Your Name"; $mail->AddAddress(" list@example.com "); $mail->Subject = "Your fancy newsletter"; $mail->IsHTML(true); $mail->AddEmbeddedImage('image.png', 'image_id', 'test.png', 'base64', 'image/png'); $mail->Body = <<<EOT <h1>My Newsletter</h1> <p>This picture is embedded in newsletter: <img src="cid:image_id" /></p> EOT; $mail->AltBody="Text only, sorry no image"; if(!$mail->Send()) { echo "Error sending: " . $mail->ErrorInfo; } else { echo "Mail is sent"; } ?>
Zz coder
source share