Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Compress email attachments

by broomduster (Priest)
on Sep 26, 2008 at 09:39 UTC ( #713835=note: print w/replies, xml ) Need Help??


in reply to Compress email attachments

Since you know about MIME::Parser, you have MIME-tools (that's where MIME::Parser comes from). The documentation for MIME-tools gives examples for decoding and encoding MIME-formatted messages. All you need is a compression step in the middle. Have a look at Compress::Zlib.

Now try this out and if you have problems, come back with sample code and a description of what works and what does not work.

Replies are listed 'Best First'.
Re^2: Compress email attachments
by luckypower (Beadle) on Sep 26, 2008 at 09:53 UTC
    Thanks..
    I am aware of these things....
    but i don't know from where to start.
    suppose the mail has following structure
    1 (mail)
    1.1 (jpg file)
    1.2 (another mail so it has its own header)
    1.2.1 (application)
    1.2.2 (video)
    ...

    so here i have to decode first msg. then second msg(1.2) to get its attachments.
    now compress attachments put them back in second msg and again put the second msg in 1st msg...
    so can i decode msgs n create files or something else..??
      If I understand this correctly, what you have is an email message with multiple MIME parts. Some of those parts are other email messages that also have MIME attachments. This is what the tools in MIME-tools (e.g., MIME::Parser) are designed to deal with.

      May I suggest that you start with something simple? Start with a message that has a single attachment. Write some test code that does what you want (extract the attachment, compress it, re-construct a properly formatted message). Then work up to more complicated schemes like the one you show here.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://713835]
help
Chatterbox?
marioroy At a large firm, had to awaken a security guy a few times so that nobody would catch him sleeping.
marioroy On a large dairy farm, almost went off the road with a 10 wheeler from exhaustion. On the farm, almost went off the silo with a big tractor. At the Fransiscan monastery, almost slipped off the dome while painting it.
[marioroy]: In Saudi Arabia caught fire but didn't burn. I think angels exist.
Lady_Aleena clean up after dinner finally.
[Discipulus]: uch! so we are twice lucky to have MCE..;=)
[marioroy]: Working a midnight graveyard shift, on the way home ran out of gas. just 2 minutes later somebody stops with a small tank of gas. It's wierd. There's always someone nearby for some reason.
[Lady_Aleena]: I was the one who stop[ed in the middle of a cold night to pick up a small family walking to a gas station. I got a few gallons of free gas for the round trip, and the grandmother said she'd pray for me.
[marioroy]: Folks do not know it, but MCE was ridiculously difficult. At Niagra Falls, heard a voice on enabling Grace while in the mist boat. That 10x performance is possible.
[marioroy]: Lady_Aleena Angels on earth are real people. That's awesome.
[Lady_Aleena]: marioroy, what does MCE stand for in this instance? There are 3 pages of abbreviations to go through.

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (11)
As of 2017-05-29 08:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?