Code: Select all
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: 7bit
<p><strong>Here</strong> is your custom report on what you wanted.</p>
Content-Type: application/octet-stream; name="Report 1.jpg"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="Report 1.jpg"
/9j/4AAQSkZJRgABAgEAYABgAAD/7ABzRHVja3kAAQAEAAAAPAADAF4AAAAtACgAYwApACAASwBl
AHYAaQBuACAARgBvAHIAZQBzAHQALwBQAGgAbwB0AG8AZABpAHMAYwAgAEcAcgBlAGUAbgAvAEcA
ZQB0AHQAeQAgAEkAbQBhAGcAZQBzAAD/4gxYSUNDX1BST0ZJTEUAAQEAAAxITGlubwIQAABtbnRy
UkdCIFhZWiAHzgACAAkABgAxAABhY3NwTVNGVAAAAABJRUMgc1JHQgAAAAAAAAAAAAAAAAAA9tYA
AQAAAADTLUhQICAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
ABFjcHJ0AAABUAAAADNkZXNjAAABhAAAAGx3dHB0AAAB8AAAABRia3B0AAACBAAAABRyWFlaAAACCode: Select all
//$fr is the mysql array for the report to be emailed
//$fde is a config mysql entry
$file = $path.$fr["fileid"];
$file_size = filesize($file);
$handle = fopen($file, "r");
$content = fread($handle, $file_size);
fclose($handle);
$content = chunk_split(base64_encode($content));
$uid = md5(uniqid(time()));
$name = basename($file);
$header = "From: Trading Sykology <".$fde["value"].">\r\n";
$header .= "Bcc: ".$fde["value"]."\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
$header .= "This is a multi-part message in MIME format.\r\n";
$header .= "--".$uid."\r\n";
$header .= "Content-Type: text/html; charset=iso-8859-1\r\n";
$header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$header .= html_entity_decode($fr["message"])."\r\n\r\n";
$header .= "--".$uid."\r\n";
$header .= "Content-Type: application/octet-stream; name=\"".$fr["fileid"]."\"\r\n"; // use diff. tyoes here
$header .= "Content-Transfer-Encoding: base64\r\n";
$header .= "Content-Disposition: attachment; filename=\"".$fr["fileid"]."\"\r\n\r\n";
$header .= $content."\r\n\r\n";
$header .= "--".$uid."--";
if (mail($t_first." ".$t_last." <".$t_email.">", $fr["name"], "", $header))
{
echo $fr["name"]." was sent successfully.<br>";
}
else
{
echo $fr["name"]." could not be sent.<br>";
}