?
Solved

Using Procmail to *modify* MIME Attachments

Posted on 2006-07-21
4
Medium Priority
?
1,134 Views
Last Modified: 2013-12-16
I want to use procmail to MODIFY an incoming MIME attachment.  Specifically, I want to rewrite .ics attachments from Apple iCal so they can be read by Microsoft Outlook.

I can set up the procmail recipes to detect the matching email, but I haven't been able to find examples of how I can MODIFY attachments (detach, modify, re-attach), so the resulting MIME email is still valid.  Because the content is encoded, I don't want to process the raw MIME data, but want to use some MIME scripts to process the attachments.

Does anyone have examples doing this kind of procmail-based transcoding of attachments?  I've heard of people deleting attachments, but I actually want to modify them.

Wisdom?
0
Comment
Question by:todd_e_bryant
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 22

Expert Comment

by:pjedmond
ID: 17159745
Outlook 2003 can 'import' ics documents, but this is a fairly complex process, and not really suited to Procmail!

However, the ability to 'strip out' attachments and 'rebuild' the email \can be done with a utility called reformime:

http://www.courier-mta.org/?reformime.html

This is the tool I use to extract attachments from emails in order to AV scan them, before they are allowed to be passed on.

(   (()
(`-' _\
 ''  ''
0
 

Author Comment

by:todd_e_bryant
ID: 17160622
Thanks pjedmond,

This looks like an interesting tool.  As I understand it, it allows you to copy different attachments from the MIME email message to standard output, or to a file.

But, I'm not completely clear how to reassemble a new message, containing a modified attachment.

My mission is to:

(1) Pull out the .ics iCalendar attachment from an incoming event notification email using procmail and other tools.
(2) Rewrite the .ics file to make Apple iCal invites compatible with Outlook 2003 (basically changing timezone formats)
(3) Replace the email with a new email that is identical, except it has the new .ics file attachment.
(4) The modified email gets dumped into my IMAP folder and read by Outlook normally.

It looks like I can get the .ics attachment using the -e option.  But I'm unclear if this helps me recreate a new MIME email message that contains the new attachment, or if I have to do that from scratch?

Thoughts if this might be relevant to my mission!
0
 
LVL 22

Accepted Solution

by:
pjedmond earned 750 total points
ID: 17160947
I'm sure that I wil be corrected on this, but as far as I'm aware, if you modify a 'mime' attachment and put it back in, the email becomes invalid due to the various 'hashes that exist. You would have to use 'reformime' to take the email completely to pieces, and then rebuild it from scratch. Many MTAs, including Sendmail support the 'putting back together process'.

Due to the complexity of what you are trying to do, I think that you need to look at the mechanism used for delivery of mail, and then use a Perl script of some sort to take the mime attachments apart completely. MIME-tools appears to fit the bill for taking apart and rebuilding the email completely.

http://www.zeegee.com/code/perl/MIME-tools/

(   (()
(`-' _\
 ''  ''
0
 

Author Comment

by:todd_e_bryant
ID: 17160997
pjedmond,

The MIME-tools package looks interesting.  Better yet, it's in perl, so I don't have to have any compilation struggles.  I'm going to give this a try, and give you the points for this recommendation.

I'm not sure that most MIME messages have checksums/hashes (I think MIME usually has well-defined text strings to define partitions between entities in most cases), but there may well be special cases and magic headers I need to worry about.  Hopefully MIME-tools will hide most of these details from me!
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month11 days, 9 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question