email

is there a way i can catch images and display them from the body of an email?
example:- if a user sends an email with a signature i want to display the signature instead of
i have attached the code im using below could someone please add to it.
[php]
002_2985BBB6F42E324FA50FFE52D648B4DE9B7472SJFEXC001SJFCSINT Content-Type: image/png; name=“image001.png” Content-Description: image001.png Content-Disposition: inline; filename=“image001.png”; size581; creation-date=“Wed, 24 Feb 2016 12:28:15 GMT”; modification-date=“Wed, 24 Feb 2016 12:28:15 GMT” Content-ID: Content-Transfer-Encoding: base64
[/php]
[php]

<?php

// Turn off all error reporting
error_reporting(0);

$mbox = imap_open(’{mail.server:110/pop3}’, ‘user’, ‘pass’)
or die("can’t connect: " . imap_last_error());

$MC = imap_check($mbox);

$compile ="";

// count how many messages and deduct 4
$count= imap_num_msg($mbox) -3;

// Fetch an overview for all messages in INBOX
//$result = imap_fetch_overview($mbox,“1:{$MC->Nmsgs}”,0);
$result = imap_fetch_overview($mbox,$count.":{$MC->Nmsgs}",0);

foreach (array_reverse($result) as $overview) {		
	$messageNo = $overview->msgno;
	//$date= $overview->date;
	//$From = $overview->from;
	$subject = $overview->subject;
	//$message_id = $overview->message_id;
	$body = imap_qprint(imap_body($mbox, $messageNo));
	//compile to string
	$compile .= "<div style='border:none;border-bottom:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p><u>".$subject."</u><br/>".$body."</div>";
} 

[/php]

Well, yes, anything in an email can be pulled out and used. The problem is that the image may be embedded or
it may be a direct link to an image on a server. I often set up a template for clients that they use to send out
automated emails from their server. If there is an image in the email such as a signature, it is usually in the form
of an image on their server. In that case, the email will have a standard tag that shows the direct link to
their server like: , etc. If so, this can be stripped out of
the email using whatever tags the sig might be inside of. The other way these images are handled is by embedded
versions. These are normally base64 encoded data which is the actual image itself. These are also usually tagged
somehow so that you can locate them and save them. Note that copying and saving or using an embedded pix
of a real signature is not completely legal. The reason being that you could use someone’s sig to spam others
and act like you are the original person. So, make sure you have permission to do this.

You can use the “imap_fetchstructure” function to get a list of parts of your message. And, you can use the
“getAttachments” if you are talking about an attached signature. If it is an embedded image, you need to pull
it out of the email into a string and then decode the base64 coded version and save as the correct filetype.
You showed a PNG version for your example which also shows it is base64 encoded and an INLINE version. This
means that it is embedded and you will need to decode it before being able to use it.

Hope that makes sense somewhat. Not sure if it gives you a real answer or not.

Sponsor our Newsletter | Privacy Policy | Terms of Service