I had actually tried that but no luck...
using file_get_contents just returns the words 'GIF89ax'... I've also tried readfile() but I still don't know how to turn the string into an attachment I can send via email...
the phpmailer AddAttachment() returns an error if I give it a URL
The last thing I tried was this:
<?php
include_once('main.inc.php');
$image_url = 'http://www.dpreview.com/Learn/Articles/Glossary/Optical/images/123di_perspec_wide_far.jpg';
function save_image($img,$fullpath) {
$ch = curl_init ($img);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
$rawdata=curl_exec($ch);
curl_close ($ch);
if(file_exists($fullpath)){
unlink($fullpath);
}
$fp = fopen($fullpath,'x');
fwrite($fp, $rawdata);
fclose($fp);
}
$image = save_image($image_url,getcwd().'/images');
$body = 'body text';
$mail->Subject = 'attachment test';
$mail->AddReplyTo('myemail@gmail.com');
$mail->AddAddress('myemail@gmail.com');
$mail->MsgHTML($body);
$mail->AddAttachment('images/'.$image);
if(!$mail->Send()) {
$notification_results = 'ERROR';
} else {
$notification_results = 'EMAIL SENT';
$mail->ClearAddresses();
}
echo $notification_results;
?>
however I get these errors:
Warning: unlink(/home/chaindlk/public_html/reviews/admin/images) [function.unlink]: Is a directory in /home/chaindlk/public_html/reviews/admin/email.php on line 13
Warning: fopen(/home/chaindlk/public_html/reviews/admin/images) [function.fopen]: failed to open stream: File exists in /home/chaindlk/public_html/reviews/admin/email.php on line 15
Warning: fwrite(): supplied argument is not a valid stream resource in /home/chaindlk/public_html/reviews/admin/email.php on line 16
Warning: fclose(): supplied argument is not a valid stream resource in /home/chaindlk/public_html/reviews/admin/email.php on line 17
Could not access file: images/ EMAIL SENT
any ideas?