Current location: Hot Scripts Forums » Programming Languages » PHP » How to email an image created on fly???


How to email an image created on fly???

Reply
  #1 (permalink)  
Old 05-13-06, 10:21 AM
nitro4file nitro4file is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
How to email an image created on fly???

Hi All,

am trying to email an image created on fly, i can email any image file etc but dunno how to do it for an image i php create.

my current code for email with attach.

PHP Code:




<?
$file 
"address.gif";
$fp fopen($file"r");
$file2 fread($fpfilesize($file));

$file2 chunk_split(base64_encode($file2));

$subject ="Image Email";
$sender "***@****.***";


$formsend mail("***@*****.***""$subject""$file2""From: $sender\r\nMIME-Version: 1.0\r\nContent-type: image/gif; name=address\r\nReply-to:$sender\r\nContent-Transfer-Encoding: base64"); 


?>
Okay the above code work and send my email with attached (address.gif),
Now i have a php suppose dynamicAddress.php, which work as follows:

dynamicAddress.php?town=20&city=10&address=somewhe re+road+etc

dynamicAddress.php fetch data from mysql and output a custom image on the screen,

Now how do i give user the possibility to email them this image which has just been created??

Thanks in advance for your reponse

Cheers
Nitro
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 05-13-06, 05:47 PM
Alli Alli is offline
Newbie Coder
 
Join Date: May 2006
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
you can store the image in server and send a html mail containing the address, or send it as an attachment. i read a great article explaining both methods wih this title "advanced mail in php" (maybe)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 05-14-06, 12:55 AM
nitro4file nitro4file is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
That's what am trying to do, but aint finding a suitable solution,

Anyone can direct me to some solution to his issue?? Thanks

Cheers
Nitro
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 05-14-06, 03:00 AM
nitro4file nitro4file is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
OK, let me simplify my question, at which stage of an image creation can i obtain binary code of same??? should i by all means save it by supplying the 3rd argument like

Imagegif($im,'img.gif',100);

then use fopen() and fread() to obtain binary data, then use chunk_split(base64_encode() to include it in my email.

Is there another means of getting the binary data without saving my image first?? if yes how to do so!

Thanks for your help

Cheers
Nitro
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 05-14-06, 03:23 AM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
The following should work -
PHP Code:

ob_start(); // turn on or start a new output buffer

Imagegif($im); // output the image to the buffer
$image_data ob_get_contents(); // get the buffer into a variable
ob_end_clean(); // discard the buffer 
You can then process the $image_data variable the same as if you had read if from a file.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???

Last edited by mab; 05-14-06 at 03:26 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 05-14-06, 01:53 PM
nitro4file nitro4file is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Mab,

I have just one word! Perfect!!

Thanks alot for your help

Cheers
Nitro
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it possible to Send an image created on fly as attachement? nitro4file PHP 2 03-05-06 10:49 AM
form to anyone's email with Image Verification ghostrider632 PHP 1 05-11-05 10:08 AM
problem sending html email + image dflip PHP 2 05-08-05 01:39 PM


All times are GMT -5. The time now is 01:10 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.