Re: [PHP-DEV] Email from HTML form + gifs From: Juan Pablo Letelier (lete <email protected>)
Date: 10/30/99

Hi Gianni :

the form may be declared :
<form ENCTYPE="multipart/form-data" action="URL" method="post">

and in the form you need put the next line
<input type="file" name="image">

this line permit that the user select some file via a select box

When the user press the button of submit the file that the ser select will
be uploaded to the server and the variable $image ( refer to the manual of
php3 for upload here say all about the manipulation of the file )

You must verify if the file have a extension of a image !

Noy you have the image in the server, referred by the variable $image
(the path only).

Now you need build the message body and the headers of the email

NOTE : You need a program called mimencode for encode the file

build the header of the email in the next way :

$mime_boundary = "-1747901728-1448367683-913849620=:4553";
$headers = "";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: MULTIPART/MIXED;boundary=\"".$mime_boundary."\"\n";
$headers .= "From : $from\n";
$headers .= "CC : $CC\n"; /* May Be Optional */
$headers .= "Reply-To : $reply\n"; /* May Be Optional */

$body .= " This message is in MIME format. The first part should be readable text,\n";
$body .= " while the remaining parts are likely unreadable without MIME-aware tools.\n";
$body .= " Send mail to mime <email protected> for more info.\n";
$body .="\n";
$body .= "--" . "$mime_boundary" . "\n";
$body .= "Content-Type: TEXT/PLAIN; charset=US-ASCII\n";
$body .= "\n";
$body .= PUT THE VARIABLE OF THE BODY OF MESSAGE
$body .= "\n\n";
$body .= "--" . $mime_boundary . "\n";
$name = $image_name;
$body .= "Content-Type: " . $this->guessMIMEType($nombre) .";name=\"".$name . "\"\n";
$body .= "Content-Transfer-Encoding: BASE64\n";
$body .= "Content-Description: $name\n";
$body .= "Content-Disposition: attachment; filename=\"".$name."\"\n";
$body .= "\n";
$pp = popen("mimencode -b $this->attachment","r");
while(!feof($pp))
{
   $data = fread($pp,4096);
   $body .= $data;
}
pclose($pp);
$body .= "--" . $mime_boundary . "--\n";
mail($to,$subject,$body,$headers);

NOTE 2 : Be sure that the program mimencode have the rights set to
execution to the user that run's apache or the web server

Bye
 LeTe

PS : If have any problem drop me a email

On Fri, 29 Oct 1999, gianni wrote:

> This message was sent from Geocrawler.com by "gianni" <gianni <email protected>>
> Be sure to reply to that address.
>
> Greetings
>
> does someone know how to add pictures to an email sent by an online form ?
>
> thanks
> gianni
>
> Geocrawler.com - The Knowledge Archive
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
> For additional commands, e-mail: php-dev-help <email protected>
> To contact the list administrators, e-mail: php-list-admin <email protected>
>

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>