bug-mailutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Any way to automatically remove attachments?


From: Jean Louis
Subject: Re: Any way to automatically remove attachments?
Date: Mon, 16 Nov 2020 01:05:21 +0300
User-agent: Mutt/2.0 (3d08634) (2020-11-07)

* Sergey Poznyakoff <gray@gnu.org.ua> [2020-11-15 23:47]:
> Jean Louis <bugs@gnu.support> ha escrit:
> 
> > Is there any way in GNU Mailutils?
> 
> No, I'm afraid there isn't any.

I am trying something like this below, but there may be bug, I will
make it soon. 

save-attachments.sh:

#!/bin/bash
# This should be executed in ~/Maildir/person@example.com

for filename in "$1"; do
    REALPATH=`realpath "$filename"`;
    DIRNAME=`dirname $REALPATH`;
    EMAILDIR=`dirname $DIRNAME`;
    EMAILDIR=`basename $EMAILDIR`;
    echo $EMAILDIR;
    extract-attachments.pl $EMAILDIR < "$filename" > "$filename".LCK && mv -v 
"$filename".LCK "$filename";
done


extract-attachments.pl:

#!/usr/bin/perl -w
# 
https://unix.stackexchange.com/questions/174707/remove-delete-attachments-from-email-server-imap#174726

# for filename in <list> 
# do 
#   ./strip.pl email@example.com < "$filename" > "$filename".lock && mv 
"$filename".lock "$filename" 
#   rm "$filename".lock
# done

use strict;
use Mail::Audit;
use Mail::Audit::Attach qw(Attach);

unless($ARGV[0])
  {
   print "Specify email address on the command line.\n";
   exit;
  }

my $mail = Mail::Audit->new;
my $attachments = $mail->attachments;
my $download = "/home/admin/attachments/" . $ARGV[0] . "/";
mkdir $download;

foreach (@$attachments)
  {
    $_->save($download);
    $_->remove;
  }
$mail->print();



reply via email to

[Prev in Thread] Current Thread [Next in Thread]