hellkvist.org Forum Index hellkvist.org
Discussions about the free software on hellkvist.org
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

manage multipart email

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    hellkvist.org Forum Index -> Peffisaur
View previous topic :: View next topic  
Author Message
cristian
Guest





PostPosted: Wed Jul 28, 2004 1:38 pm    Post subject: manage multipart email Reply with quote

Hi all

I install peffisaur on my server and everything works fine in email-mode except for one mobile operator that send a strange mms via email.

The message (msgtxt) is into an html email !!!

Ho can I modify the recmail.pl script to read and save this message from the html ??

Any idea ??

Ciao and thank you !
Back to top
Peffis
Site Admin


Joined: 09 Sep 2003
Posts: 324
Location: Sweden

PostPosted: Wed Jul 28, 2004 2:16 pm    Post subject: Reply with quote

I see. The changes require some perl knowledge I'm afraid. You should have a look at the getTextForMid function in recmail.pl. First change the SQL query so that it says
Code:
SELECT fname FROM content WHERE mid=$mid && (contenttype='text/plain' || contenttype='text/html')
instead of what it currently says.

Then after the line
Code:
@content = <TXTFILE>
you will have to strip all HTML tags from the message if you want to have a clean message. Or perhaps you could ignore this step and add strip_tags in the showPost method in lib.php instead so that tags are removed before display. Take your pick.
Back to top
View user's profile Send private message Visit poster's website
cristian
Guest





PostPosted: Wed Jul 28, 2004 2:53 pm    Post subject: multipart mms-email Reply with quote

Thank you for your reply but the problem is that after the unpack process into the msgstore->email folder i don't have any msg txt file!!

I notice that the message is only in to the html that we can see into the email client.

So I think that the only way is to save the message from the while cicle into the recmail.pl. (where we assing $to, $from, $subject ...)

Ciao
Back to top
Peffis
Site Admin


Joined: 09 Sep 2003
Posts: 324
Location: Sweden

PostPosted: Wed Jul 28, 2004 4:42 pm    Post subject: Reply with quote

Hmmm, so munpack doesn't manage to extract the html-part? I thought that was sent just as any other attachment, but it was a long time ago since I had a look at email at that level. Perhaps there is some exception here that munpack doesn't handle, or perhaps there is some switch that you can apply to munpack to make it work. Could you send me a sample message on email if you have one? I could have a look perhaps.

Extracting and storing the message in the beginning is a bit tricky really. The process is reading from standard in and after processing the headers (such as to, from and so on) stdin is piped on to munpack. So if you read through the message and storing it to file there would be nothing left for munpack to read. But you could of course then pipe the just stored file to munpack instead and you are all done.

I'm thinking that there must probably be hundreds of perl modules out there that does exactly this - parsing email and extracting parts like munpack does it. Perhaps one could consider rewriting the script completely later on. I also think there is email-parsing support in PHP even. Perhaps the script should be in PHP instead, thus it could use the same config file and have the whole thing in the same language. As it is now, the email support is just a quick hack as you can see.
Back to top
View user's profile Send private message Visit poster's website
cristian
Guest





PostPosted: Wed Jul 28, 2004 6:25 pm    Post subject: Reply with quote

If you want I can send you an MMS - email with this mobile operator and you can show wath happen?

What do you think ??

Ciao

Cristian
Back to top
Peffis
Site Admin


Joined: 09 Sep 2003
Posts: 324
Location: Sweden

PostPosted: Wed Jul 28, 2004 6:34 pm    Post subject: Reply with quote

Yes, do that! (I suppose you have my email address)
Back to top
View user's profile Send private message Visit poster's website
cristian
Guest





PostPosted: Wed Jul 28, 2004 9:34 pm    Post subject: Reply with quote

Yes I have your email address and just now I send you the MMS.

Ciao
Back to top
Peffis
Site Admin


Joined: 09 Sep 2003
Posts: 324
Location: Sweden

PostPosted: Thu Jul 29, 2004 6:09 pm    Post subject: Reply with quote

Thanks, for that particular message you will really need to do some parsing to get the message out because it's deep down there within the nested tables. I'm afraid I don't have the time to do that specific parsing for you right now so I would stick with the idea of writing it all to a file first, detect and parse the HTML and then pass the rest to munpack.

I still haven't tested to unpack it though. I'll do that and see if munpack does unpack the html-content or not.
Back to top
View user's profile Send private message Visit poster's website
cristian
Guest





PostPosted: Thu Jul 29, 2004 11:32 pm    Post subject: Reply with quote

Thank you for your help!

Into your last post I found the key!!!!

munpack option -t save the html into the email folder and so I need only a perl script to extract the message from html.

Thank you,

Cristian
Back to top
Peffis
Site Admin


Joined: 09 Sep 2003
Posts: 324
Location: Sweden

PostPosted: Fri Jul 30, 2004 3:17 pm    Post subject: Reply with quote

That's great! Thanks for sharing that info.

If it was only removal of tags you were after there are tons of perl lines out there on the net. Unfortunately in your example there is lots of other junk as well, such as operator messages, so it will take some parsing unfortunately. But perhaps it can be made simple and hard-coded, like taking the 5th (I haven't counted) "<td>" from the start or something
Back to top
View user's profile Send private message Visit poster's website
cristian
Guest





PostPosted: Fri Jul 30, 2004 6:09 pm    Post subject: Reply with quote

I think that I found the solution.

Whit a perl script I found the text between a specific and distinct html tag (table cell).

The script works well but I have a strange character at the end of the text. Now I try to remove with chomp() function.

What do you think ??

Executing the script terminal side I don't have this character. But with the recmail.pl found it into my Mysql field.

Ciao and thank you.
Back to top
Peffis
Site Admin


Joined: 09 Sep 2003
Posts: 324
Location: Sweden

PostPosted: Sun Aug 01, 2004 8:19 pm    Post subject: Reply with quote

Hmm, I don't know really where that character can come from. But chomping it off of cutting off the last char should do the trick if it's there all the time I guess.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    hellkvist.org Forum Index -> Peffisaur All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group