Extracting mime parts from oversize emails
Sometimes people have the strange idea to send files via email, despite it being a method of communication and not file transfer. Emails encounter a 34% overhead for the transfer of files! Compared to <1% for HTTP, FTP and SCP.
Install mpack to get the munpack utility.
The email can then be pilled/saved from the mail server into a text file that can be unpacked into the current directory:
$ munpack -f -t email.eml part1 (text/plain) part2 (text/html) archive.zip (application/x-zip-compressed)
- -f - overwrite any existing files
- -t - extract the text & html parts as files too
If delivering the original email after deleting the oversize attachments, the email filename needs to be fixed up so that the size parameter in the filename is accurate to the size again.
eg. 1600997372.H912871P7416.niobium.linuxwan.net,S=39141093:2,
This filename needs to have its size fixed. We do this by counting the bytes of the file. A ls -la will give you this value, or you can run wc -c filename.
Resulting filename 1600997372.H912871P7416.niobium.linuxwan.net,S=15738:2,