Monday 23 December 2013

How to Attacch File/Image From External URL(remote file/image) to e-mail


How to Attacch File/Image From External URL to e-mail Iam Previously explain about sending e-mails using PHPmailer and Gmail server in this added a code for attachment File/Image from Folder But
Now i'am Explain about how to attach a File/Image from External URl.

General File/Image attachemnet:
$mail->AddAttachment("images/kc_logo.jpg");
File/Image attachment from Remote:
$string = file_get_contents("http://sri-knowledgecorner.rhcloud.com/images/blogicon.jpeg"); 

$mail->AddStringAttachment($string, "01182013_220715.jpg", $encoding = 'base64', $type = 'application/octet-stream');
In case file_get_cotents field to load file use cURL,
Read More info about file_get_contents and cURL Click Here