Page 1 of 1

Bringing up PHP GD problem again, help please

Posted: Thu May 31, 2007 1:38 am
by violet
I'm (still) trying to send a PHP GD image as a form-to-mail attachment. I have this:

Code: Select all

$im = image.php
in my sendmail.php.

I'm using file_get_contents() but I think the parameters in the parentheses shouldn't be:

Code: Select all

$file =	file_get_contents($im, 'rb');
because that way I literally get the contents of $im:

Code: Select all

<?php header("Content-type:image/gif");
	$image = imagecreatetruecolor(231,200) or die ("Cannot create image");
 	$black = imagecolorallocate($image,0,0,0);
	$white = imagecolorallocate($image,255,255,255);

etcetera
Thing is, how do I call/get the processed contents of $im in my sendmail.php?

Help please... :?

P.S.
This is part of my sendmail.php.. Please correct all that looks wrong:

Code: Select all

$file =	file_get_contents($im, 'rb');
ob_start(); 
imagegif($im, '', 70); 
$file = ob_get_clean(); 

$message .=	"Content-Type: image/gif; name=\"image.gif\"\r\n" 
 	."Content-Transfer-Encoding: base64\r\n"
 	."Content-disposition: attachment; file=\$im\r\n"
	."\r\n"
 	.chunk_split(base64_encode($file))
 	.$bound_last; 

Posted: Thu May 31, 2007 2:35 am
by volka
remove the header("Content-type:image/gif"); from image.php
use require() instead of file_get_contents()
There is no third parameter for imagegif()
You might be interested in http://swiftmailer.sf.net

Posted: Thu May 31, 2007 6:06 am
by violet
Thank you thank you thank you, volka! :) I will try this ASAP!

I have tried Swiftmailer but to be completely honest with you, I couldnt' figure out how to use it.. A 'Swiftmailer for Dummies' would probably be very useful :D

Posted: Thu May 31, 2007 6:13 am
by volka

Posted: Thu May 31, 2007 8:51 am
by violet
It worked, volka!!! Image