/* for every email… */ foreach ($emails as $email_number) { //$message = imap_fetchbody($inbox,$email_number,1); $overview = imap_fetch_overview($inbox, $email_number, 0); $header = imap_headerinfo($inbox, $email_number, 1); /* echo '<pre>';print_r($overview); print_r($header);die; */ $imapMsgParts = $mailbox->getMail($overview[0]->uid); //echo '<pre>';print_r($imapMsgParts);die; $message = $imapMsgParts->textPlain; //textHtmlOriginal//textHtml;//imap_fetchbody($inbox,$email_number,1); $only_reply = $message; if ($base64_msg = base64_decode($message, true)) { $message = $base64_msg; } $message = convert_ascii($message); $savedirpath = "/tmp/"; $message1 = array(); $message1["attachment"]["type"][0] = "text"; $message1["attachment"]["type"][1] = "multipart"; $message1["attachment"]["type"][2] = "message"; $message1["attachment"]["type"][3] = "application"; $message1["attachment"]["type"][4] = "audio"; $message1["attachment"]["type"][5] = "image"; $message1["attachment"]["type"][6] = "video"; $message1["attachment"]["type"][7] = "other"; $mail = @$header->sender['0']->mailbox; $hostid = @$header->sender['0']->host; $mail_id = $mail . "@" . $hostid; //mail id of sender $sender_name = isset($header->sender['0']->personal) ? $header->sender['0']->personal : $mail;
$purple = imagecolorallocate($img, 0, 42, 84); $orange = imagecolorallocate($img, 245, 159, 25); imagefill($img, 0, 0, $bgcolor); // Put in the images for ($i = 0; $i < count($image); $i++) { $im = imagecreatefrompng($image[$i]['file']); // echo $image[$i]['file']; list($width, $height) = getimagesize($image[$i]['file']); $new_width = $image[$i]['width']; $new_height = $image[$i]['height']; imagecopyresized($img, $im, $image[$i]['startX'], $image[$i]['startY'], 0, 0, $new_width, $new_height, $width, $height) or die("Error resizing"); //die(); } for ($i = 0; $i < count($text); $i++) { if ($text[$i]['fontcolor'] == "purple") { $textcolor = $purple; } elseif ($text[$i]['fontcolor'] == "orange") { $textcolor = $orange; } $string = convert_ascii(utf8_decode($text[$i]['text'])); //die($string); imagettftext($img, $text[$i]['fontsize'], 0, $text[$i]['startX'], $text[$i]['startY'], $textcolor, "./arial.ttf", $string); } if ($barcode['url']) { $bc = imagecreatefrompng($barcode['url']); imagecopyresized($img, $bc, $barcode['startX'], $barcode['startY'], 0, 0, $barcode['width'], $barcode['height'], $barcode['width'], $barcode['height']); } // End that image header('Content-type: image/png'); imagepng($img); imagedestroy($img);