0

I manage a Linux mail server (qmail) for a small office employees thought well to make a signature with 4 logos, one of which is 2 Mb. No one noticed until the mail service began to finish the space.

Now I find myself thousands of email sent containing this logo.

I would like to leave the emails and attachments intact and remove this logo or alternatively replace it with a lighter logo.

Is there a way to delete a specific attached file from a mail via Linux bash ?

file

-rw -r - r-- 1 root root 2551077 20 Jun 11:56 1528905708.M14375P5208.32432, S = 2551077, W = 2586131: 2, S
-rw -r - r-- 1 root root 2815315 20 Jun 11:56 1528911188.M719953P6580.234, S = 2815315, W = 2854016: 2, S

This is a part of mail:

Content-Type: image / gif;
    name = "image008.gif"
Content-Transfer-Encoding: base64
Content-ID: <part5.A1202B56.2A25453C @ *****>
Content-Disposition: inline;
    filename = "image008.gif"

dsfkldslkfjdslkfjdklsfjdlskfjdlskfjdlsk

Can I only remove this image for ALL MAIL (I think I use loop bash) ?

If you need another information please write.

Thanks.

jww
  • 97,681
  • 90
  • 411
  • 885
  • too hard , I wrote too many script for mail servers and actually i think can not do this . – mah454 Jun 20 '18 at 10:46
  • improved formatting – Armali Jun 20 '18 at 10:56
  • Probably possible by chaining grep to find the line containing `Content-type: multipart/mixed; boundary=...`, cut to extract the boundary, csplit (or split) to split the mail in its different parts, grep again to idendify the part to be removed and cat to concat everything back. The hard part is that bash is not very good for exceptional conditions handling and if I had to to that, I would use Python instead – Serge Ballesta Jun 20 '18 at 12:06

0 Answers0