0

I have loaded an image from a file then added text to that image via PHP.

I now need to email that image off with the text on it. I have not saved the image on the server so normal image attachments dont seem to work.

This is the image PHP to send to a browser

// Send Image to Browser
  imagejpeg($jpg_image);

  // Clear Memory
  imagedestroy($jpg_image);

and I tried to add it to this script to send the email.

  $message = "Result \r\n";
  $message .= $jpg_image;

  $to = $email;
  $subject = "Result";
  $headers = "From: results@url.com\r\n";
  $headers .= "Reply-To: user@url.com\r\n";
  $headers .= "Return-Path: user@url.com\r\n";
  $headers .= "BCC: user2@url.com\r\n";

  mail($to, $subject, $message, $headers);
Renegade Rob
  • 393
  • 1
  • 4
  • 21
  • 1
    *"I have not saved the image on the server so normal image attachments dont seem to work."* - depends on how you used it. Plus, when sending/attaching an image (being from an external source, being your server to the user), it requires a full http:// call to the image if you weren't doing that. Plus, you also need to send as HTML if the image is to be viewed from their inbox. – Funk Forty Niner Dec 23 '15 at 03:17
  • `mail()` is limited - phpmailer or swiftmailer is the go to for most of us –  Dec 23 '15 at 03:19
  • Hi @Fred-ii- I created the image in PHP, adding text etc. The image created does not have a full URL, as its only a variable and not a file? I dont want to save the image everytime it changes when someone looks at it. – Renegade Rob Dec 23 '15 at 03:21
  • I believe you'll need to send it as an HTML email. Checkout sending HTML emails here [link](http://www.w3schools.com/php/func_mail_mail.asp) – RoyaleWCheese1 Dec 23 '15 at 03:21
  • Hiya... see these Q&A's http://stackoverflow.com/q/7288614/ and http://stackoverflow.com/q/35879/ and http://stackoverflow.com/q/4312687/ they should give you a few ideas ;-) embed it. – Funk Forty Niner Dec 23 '15 at 03:23

0 Answers0