PHP Classes

sort out messages

Recommend this page to a friend!

      POP3 e-mail client  >  All threads  >  sort out messages  >  (Un) Subscribe thread alerts  
Subject:sort out messages
Summary:how to sort it out
Messages:62
Author:vlad
Date:2008-12-11 04:38:15
Update:2009-03-20 04:16:29
 
  1 - 10   11 - 20   21 - 30   31 - 40   41 - 50   51 - 60   61 - 62  

  31. Re: sort out messages   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-01-15 03:52:29 - In reply to message 29 from vlad
The class does not save message parts to temporary files. The files are not deleted after you run the script, even if you choose /tmp as directory to save message body parts.

The class saves message body parts to numbered files. It does not use the original file names for security reasons. A specially crafted message could contain an attached file with a name that could overwrite files in your system and so open holes in your PHP server.

Still the original file name, if present, is returned in the FileName entry of the message part definition. I do not advise using this file name to rename the original message body part file. At least you should filter it to discard harmful characters using the PHP basename() function. Still it may generate names that may be invalid in your system.

As for opening the attachment files, it depends on you want to do with the files. You do not need to have a file name extension to do anything useful with it.

  32. Re: sort out messages   Reply   Report abuse  
Picture of vlad vlad - 2009-01-15 04:02:17 - In reply to message 31 from Manuel Lemos
i would save all the attachments in some folder and attachments name i would put into DB so the attachment can be viewed by the clicking the link.

i agree with security reasons.
so how do you advice to write the body message into database? i mean where is it? how to get it?

i used today the function from here
phpclasses.org/discuss/package/3169 ...

but it doesnt read all my emails.

what kind of function do you advice to read the email body message?

thanks

  33. Re: sort out messages   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-01-15 04:44:57 - In reply to message 32 from vlad
It is better that you do not use code that you do not understand.

If you want to use the message body parts as data, just do not use the SaveBody parameters. The class will return message parts as strings. But be warned that if somebody sends you a message that has large attachments, you may exceed PHP memory limits and your script will abort right away.

Saving message body parts to files is safer, but if you really want to save message parts in a database without running out of memory, you should use a database that supports prepared queries and BLOBs.

  34. Re: sort out messages   Reply   Report abuse  
Picture of vlad vlad - 2009-01-16 01:30:08 - In reply to message 33 from Manuel Lemos
thanks for your advices
ive found a compromise:

im not going to save attachments at the web-server.
i will only save the attachment name. (to view an attachment user will open outlook)

i will need to extract only body email message and wright it into database.
it makes it easier.

how would you advice safely to extract the body message?


  35. Re: sort out messages   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-01-16 02:36:55 - In reply to message 34 from vlad
I am not sure what is your goal, but I think you should save the whole message data in the database in BLOB table fields and only parse the message when you need to display it to the users.

The problem is that e-mail messages can arrive in many formats, like plain text, HTML, text and HTML, text and HTML with images and CSS, and many other format variants that you cannot fully anticipate because there can be infinite combinations.

So, if you use the Decoded and then Analyze function, you can get a simplified view of each message, and do whatever you want just when you need to display to the user of process the message somehow.

Just be careful with the attachments if you intend to use the original file names. You also need to be careful when display messages with HTML parts, because these can have Javascript code that when display to the user may steal the browser cookies and send to a remote site, thus performing cross-site scripting attacks. This can be used to steal logged user session cookies and abuse the user privileges.

To avoid this problem always filter Javascript from HTML messages before displaying it to the user in a Web page. Here you can read more about this type of attacks and how to prevent them.

phpclasses.org/blog/post/55-Improve ...

  36. Re: sort out messages   Reply   Report abuse  
Picture of vlad vlad - 2009-01-22 01:01:13 - In reply to message 35 from Manuel Lemos
thanks for all your valuable advices!

i understand that
if i use the Decoded and then Analyze function, i can get a simplified view of each message, and do whatever i want just when i need to display to the user of process the message somehow.

im keep trying to figure it out and i get all the info in array (headers, subjects, etc.) except the message itself! i got the info about message. which temp file it goes and how big is it etc. but i need to lockate the message!
also i tried as an example
test_message_decoder.php but it also doesnt give the message itself.

Do you have some simple script or some function that will retrieve the message from those Decoded and then Analyze functions please?

  37. Re: sort out messages   Reply   Report abuse  
Picture of vlad vlad - 2009-01-22 01:28:26 - In reply to message 36 from vlad
hold up please
i think i figured it out..... :)

  38. Re: sort out messages   Reply   Report abuse  
Picture of vlad vlad - 2009-01-22 01:52:56 - In reply to message 37 from vlad
i did with your code at the brows mails box.php page next:

$parameters=array(
'File'=>$message_file,
Data'=>'My message data string',
// 'SaveBody'=>'tmp',
// 'SkipBody'=>1,
);

and stroke below output the body message:
echo $decoded[0]['Parts'][0]['Body'];

however not all the messages it outputs. some of the messages (i guess HTML and some others) for some reason do not displays..
why do you think?

  39. Re: sort out messages   Reply   Report abuse  
Picture of vlad vlad - 2009-01-22 02:01:54 - In reply to message 38 from vlad
however the array

print_r($decoded);

displays all the messages .....

  40. Re: sort out messages   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-01-22 02:20:31 - In reply to message 36 from vlad
The question is what is the "message" in your conception? Is it the text part or the HTML part if it exists, or is it the whole message with headers and body?

 
  1 - 10   11 - 20   21 - 30   31 - 40   41 - 50   51 - 60   61 - 62