From: Alex on
Hi,

Where can I go to find information on how to modify the content of the
body of an email before delivering?

I would like to experiment with changing "curse words" or removing
URLs like "<a href=....>" ?

I realize there are all kinds of problems with doing this, such as
modifying the signature and size of messages, but it's acceptable
tradeoff for now.

I'd really like to be able to do this with a perl script rather than
having to install some additional program like amavisd. Maybe
something like alterMIME?

Thanks,
Alex

From: Noel Jones on
On 5/19/2010 6:50 AM, Alex wrote:
> Hi,
>
> Where can I go to find information on how to modify the content of the
> body of an email before delivering?
>
> I would like to experiment with changing "curse words" or removing
> URLs like "<a href=....>" ?
>
> I realize there are all kinds of problems with doing this, such as
> modifying the signature and size of messages, but it's acceptable
> tradeoff for now.
>
> I'd really like to be able to do this with a perl script rather than
> having to install some additional program like amavisd. Maybe
> something like alterMIME?
>
> Thanks,
> Alex


You can use smtp_header_checks and smtp_body_checks with the
REPLACE action to make minor changes to mail content during
delivery. These are rather simple tools by design, best
suited for easily defined transformations.

IIRC altermime is better suited for removing attachments or
adding disclaimers. I don't think it will help with replacing
words or URLs.

There are some regexp based milters that may give you more
control.

Enjoy your experiment, but in the end you're much better off
rejecting messages with content you don't like rather than
trying to fix it.


-- Noel Jones

From: Alex on
Hi,

> You can use smtp_header_checks and smtp_body_checks with the REPLACE action
> to make minor changes to mail content during delivery.  These are rather
> simple tools by design, best suited for easily defined transformations.

Thanks for the notes. If I were to do it the right way, how would I go about it?

Is it possible to strip the entire HTML content and pass only the
text? Perhaps the right way to say it would be to pass only the MIME
text and strip everything else?

Thanks again,
Alex

From: Noel Jones on
On 5/19/2010 3:30 PM, Alex wrote:
> Hi,
>
>> You can use smtp_header_checks and smtp_body_checks with the REPLACE action
>> to make minor changes to mail content during delivery. These are rather
>> simple tools by design, best suited for easily defined transformations.
>
> Thanks for the notes. If I were to do it the right way, how would I go about it?
>
> Is it possible to strip the entire HTML content and pass only the
> text? Perhaps the right way to say it would be to pass only the MIME
> text and strip everything else?
>

Yes, you can probably do something like that with MIMEDefang.

-- Noel Jones

From: Jeroen Geilman on
On 05/19/2010 10:30 PM, Alex wrote:
> Hi,
>
>
>> You can use smtp_header_checks and smtp_body_checks with the REPLACE action
>> to make minor changes to mail content during delivery. These are rather
>> simple tools by design, best suited for easily defined transformations.
>>
> Thanks for the notes. If I were to do it the right way, how would I go about it?
>
> Is it possible to strip the entire HTML content and pass only the
> text? Perhaps the right way to say it would be to pass only the MIME
> text and strip everything else?
>
> Thanks again,
> Alex
>

I found this fantastic little util called "mailtextbody" - it does just
that: strips off all non-text parts and leaves a clean, text-only message.
Really, content processing should be left to non-MTA programs.