By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,722 Members | 1,174 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,722 IT Pros & Developers. It's quick & easy.

How to email a image in attachment

P: n/a
I create an image on the fly, and want to email it to the receiver.
But I can't. Since the php mail function needs string as message to
send the the message, but I only get my gd resource object, how can I
get the string presentation of the GD resourse.
BTW:I don't want to save it as a file first, then read from file.
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
*** wilson galaxy wrote/escribió (25 Oct 2004 08:46:02 -0700):
I create an image on the fly, and want to email it to the receiver.
But I can't. Since the php mail function needs string as message to
send the the message, but I only get my gd resource object, how can I
get the string presentation of the GD resourse.
BTW:I don't want to save it as a file first, then read from file.


The mail() function is pretty simple. Unless you are willing to write all
code from scratch, you'd better find a class with support from MIME
attachments. Check here:

http://pear.php.net/packages.php?catpid=14&catname=Mail
--
-- Álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--
Jul 17 '05 #2

P: n/a
Hello,

On 10/25/2004 12:46 PM, wilson galaxy wrote:
I create an image on the fly, and want to email it to the receiver.
But I can't. Since the php mail function needs string as message to
send the the message, but I only get my gd resource object, how can I
get the string presentation of the GD resourse.
BTW:I don't want to save it as a file first, then read from file.


You may want to try this class that lets you compose and send messages
with attached images or even embedded in HTML message body if you would
like that:

http://www.phpclasses.org/mimemessage
--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Jul 17 '05 #3

P: n/a
Thanks guy!!
My issue is I don't have a real file of this image, all I have is a gd
resource object, It seems all mail functions require either the file
name, or the string presentation of the image file. And I can not find
a way to get the string presentation of my gd resource. I am in php 4
not php 5 .

Thanks

Jul 17 '05 #4

P: n/a
Hello,

On 10/25/2004 04:38 PM, yi*******@yahoo.com wrote:
Thanks guy!!
My issue is I don't have a real file of this image, all I have is a gd
resource object, It seems all mail functions require either the file
name, or the string presentation of the image file. And I can not find
a way to get the string presentation of my gd resource. I am in php 4
not php 5 .


No, the MIME message can also take data in strings to add as
attachments. The example demonstrates that.

As for capturing the GD output as a string, try using output buffering:

ob_start()
ImageGIF($im);
$image_data=ob_get_contents();

--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.