note 11060 deleted from function.mail by jimw

From: Date: Wed, 31 Oct 2001 23:11:58 +0000
Subject: note 11060 deleted from function.mail by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-19893@lists.php.net to get a copy of this message
The next biggest thing I get questions on is how to send an email attachment. The first step to this is to read in the file you want to attach and encode it properly. Here is a little function to do just that: function encode_file ($filename){ // open a file pointer to the file $fp = fopen ( $filename, r ); // read in the entire contents of the file into a variable $contents = fread ( $fp, filesize($fp)); // close the file fclose ( $fp ); // encode the file $encoded_file = chunk_split ( base64_encode ( $contents ) ); // return the encoded file return $encoded_file; } You will also have to set up the proper headers etc... If there is more interest in this I could write a tutorial on it and an object library. :)

« previous php.notes (#19893) next »