Here is how I am attaching a file to an email -
for($i=0;$i<$max;$i++)
{
$file = fread(fopen($this->attachment[$i], "r"), filesize($this->attachment[$i]));
$this->header .= "--".$this->boundary."\n";
$this->header .= "Content-Type: application/x-zip-compressed; name=".$this->attachment[$i]."\n";
$this->header .= "Content-Transfer-Encoding: base64\n";
$this->header .= "Content-Disposition: attachment; filename=".$this->attachment[$i]."\n\n";
$this->header .= chunk_split(base64_encode($file))."\n";
$file = "";
}
Weedpacket, to incorporate you suggestion, how do I give the buffer a filename so it sits in the email as a .jpg file to be viewed?
The reason I don't want to create the imagefile on the server then attach it to the email is that the image file is previewed by the user on the website then emailed to them as confirmation and for their records. I have no use in retaining the file and certainly don't want it to clutter up my web server with an image file for every transaction.
Any ideas?