stupid question about removing maildir attachments

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

stupid question about removing maildir attachments

Eero Volotinen-2
Hi list,

A bit offtopic, but I need cli-tool to remove attachments from specific maildir messages, so how to do that?

Eero
Reply | Threaded
Open this post in threaded view
|

Re: stupid question about removing maildir attachments

Bill Cole-3
On 29 Dec 2017, at 15:15 (-0500), Eero Volotinen wrote:

> Hi list,
>
> A bit offtopic, but I need cli-tool to remove attachments from
> specific
> maildir messages, so how to do that?

You're on the wrong list. I don't know what the right one for this query
would be, but it's going to depend on what you have reading your
maildirs (i.e. your POP, IMAP, or webmail server, NOT Postfix) because
that's the side you risk confusing by doing that.

As a general rule, I'd say that you would be better off reconsidering
your problem from its root and finding an alternative mechanism.
Modifying message files in a maildir after they've been delivered rarely
ends well. You'd be better off using something like MIMEDefang to lop
off the attachments before delivery or an IMAP client to do the surgery
by reconstructing a new message sans attachment and deleting the
original.

--
Bill Cole
[hidden email] or [hidden email]
(AKA @grumpybozo and many *@billmail.scconsult.com addresses)
Currently Seeking Steady Work: https://linkedin.com/in/billcole
Reply | Threaded
Open this post in threaded view
|

Re: stupid question about removing maildir attachments

Alex JOST-2
In reply to this post by Eero Volotinen-2
Am 29.12.2017 um 21:15 schrieb Eero Volotinen:
> Hi list,
>
> A bit offtopic, but I need cli-tool to remove attachments from specific
> maildir messages, so how to do that?

The Thunderbird add-on 'AttachmentExtractor' should be able to do that,
but I don't know if it still works with recent versions of Thunderbird
as it hasn't been updated in a long time.

As Bill already noted such operations should be considered wisely. Wrong
manipulation of the message can make it unreadable. Backups are mandatory.

--
Alex JOST
Reply | Threaded
Open this post in threaded view
|

Re: stupid question about removing maildir attachments

Marat Khalili
In reply to this post by Eero Volotinen-2
Python has MIME parsing and authoring tools in standard library, but performance can be a bit slow (several gigabytes per hour in my experience).
--

With Best Regards,
Marat Khalili
Reply | Threaded
Open this post in threaded view
|

Re: stupid question about removing maildir attachments

Voytek
In reply to this post by Alex JOST-2
On Mon, January 1, 2018 1:19 am, Alex JOST wrote:
> Am 29.12.2017 um 21:15 schrieb Eero Volotinen:

>> A bit offtopic, but I need cli-tool to remove attachments from specific
>>  maildir messages, so how to do that?
>
> The Thunderbird add-on 'AttachmentExtractor' should be able to do that,
> but I don't know if it still works with recent versions of Thunderbird as
> it hasn't been updated in a long time.
>
> As Bill already noted such operations should be considered wisely. Wrong
> manipulation of the message can make it unreadable. Backups are mandatory.


I'm happy to be corrected here, but, I'm fairly certain I have done so in
the past, with no ill effect, and, one can always copy the actual file to
a new file, anyhow.

it was i think uudecode ? first for uuencoded emails, and, munpack for
mime encoded, something like 'munpack email_file':

NAME
       munpack - unpack messages in MIME or split-uuencode format

SYNOPSIS
       munpack [ -f ] [ -q ] [ -t ] [ -C directory ] [ filename ...  ]

DESCRIPTION
       The munpack program reads each RFC-822 message filename and writes
all non-text MIME parts or
       split-uuencoded files as files.  If no filename argument is given,
munpack reads  from  stan-
       dard input.


Reply | Threaded
Open this post in threaded view
|

Re: stupid question about removing maildir attachments

Bill Cole-3
On 31 Dec 2017, at 10:24 (-0500), Voytek wrote:

> On Mon, January 1, 2018 1:19 am, Alex JOST wrote:
>> Am 29.12.2017 um 21:15 schrieb Eero Volotinen:
>
>>> A bit offtopic, but I need cli-tool to remove attachments from
>>> specific
>>>  maildir messages, so how to do that?
>>
>> The Thunderbird add-on 'AttachmentExtractor' should be able to do
>> that,
>> but I don't know if it still works with recent versions of
>> Thunderbird as
>> it hasn't been updated in a long time.
>>
>> As Bill already noted such operations should be considered wisely.
>> Wrong
>> manipulation of the message can make it unreadable. Backups are
>> mandatory.
>
>
> I'm happy to be corrected here, but, I'm fairly certain I have done so
> in
> the past, with no ill effect, and, one can always copy the actual file
> to
> a new file, anyhow.
>
> it was i think uudecode ? first for uuencoded emails, and, munpack for
> mime encoded, something like 'munpack email_file':

Yes, but that does not *remove* the attachments from the existing
message file. It extracts decoded copies of the attachments. The
original message file is unmodified.


--
Bill Cole
[hidden email] or [hidden email]
(AKA @grumpybozo and many *@billmail.scconsult.com addresses)
Currently Seeking Steady Work: https://linkedin.com/in/billcole
Reply | Threaded
Open this post in threaded view
|

Re: stupid question about removing maildir attachments

Eero Volotinen-2
Well. I took this source (https://github.com/gitpan/Mail-Box/blob/master/examples/strip-attachments.pl) and modified it to work with maildirs.

It even keeps original untouched, so backups are also available :)

Eero

2017-12-31 18:43 GMT+02:00 Bill Cole <[hidden email]>:
On 31 Dec 2017, at 10:24 (-0500), Voytek wrote:

On Mon, January 1, 2018 1:19 am, Alex JOST wrote:
Am 29.12.2017 um 21:15 schrieb Eero Volotinen:

A bit offtopic, but I need cli-tool to remove attachments from specific
 maildir messages, so how to do that?

The Thunderbird add-on 'AttachmentExtractor' should be able to do that,
but I don't know if it still works with recent versions of Thunderbird as
it hasn't been updated in a long time.

As Bill already noted such operations should be considered wisely. Wrong
manipulation of the message can make it unreadable. Backups are mandatory.


I'm happy to be corrected here, but, I'm fairly certain I have done so in
the past, with no ill effect, and, one can always copy the actual file to
a new file, anyhow.

it was i think uudecode ? first for uuencoded emails, and, munpack for
mime encoded, something like 'munpack email_file':

Yes, but that does not *remove* the attachments from the existing message file. It extracts decoded copies of the attachments. The original message file is unmodified.



--
Bill Cole
[hidden email] or [hidden email]
(AKA @grumpybozo and many *@billmail.scconsult.com addresses)
Currently Seeking Steady Work: https://linkedin.com/in/billcole

Reply | Threaded
Open this post in threaded view
|

Re: stupid question about removing maildir attachments

@lbutlr
In reply to this post by Bill Cole-3
On 31 Dec 2017, at 09:43, Bill Cole <[hidden email]> wrote:
> On 31 Dec 2017, at 10:24 (-0500), Voytek wrote:
>> On Mon, January 1, 2018 1:19 am, Alex JOST wrote:
>>> Am 29.12.2017 um 21:15 schrieb Eero Volotinen:

>>>> A bit offtopic, but I need cli-tool to remove attachments from specific
>>>> maildir messages, so how to do that?

>>> The Thunderbird add-on 'AttachmentExtractor' should be able to do that,
>>> but I don't know if it still works with recent versions of Thunderbird as
>>> it hasn't been updated in a long time.

>>> As Bill already noted such operations should be considered wisely. Wrong
>>> manipulation of the message can make it unreadable. Backups are mandatory.

>> I'm happy to be corrected here, but, I'm fairly certain I have done so in
>> the past, with no ill effect, and, one can always copy the actual file to
>> a new file, anyhow.
>>
>> it was i think uudecode ? first for uuencoded emails, and, munpack for
>> mime encoded, something like 'munpack email_file':

> Yes, but that does not *remove* the attachments from the existing message file. It extracts decoded copies of the attachments. The original message file is unmodified.

I think using dovecot and sieve would be possible to do this, but as others have said this seems to be trying to solve the wrong problem.

If the attachments are not wanted, it seems unlikely the mail itself is wanted, better to reject.

--
Wally: That's my nickname, "Waly" with one el. Dilbert: Who calls you
that? Wally: Most people, they just don't realize it.

Reply | Threaded
Open this post in threaded view
|

Re: stupid question about removing maildir attachments

Eero Volotinen-2
Well, case is that I want to migrate from postfix to google g-suite and they don't accept mails bigger than 50M. 

So, I need to strip and save old attachments and upload them to google drive. (stupid limit, but it exists without change to modify it)

Eero

Eero

31.12.2017 20.21 "@lbutlr" <[hidden email]> kirjoitti:
On 31 Dec 2017, at 09:43, Bill Cole <[hidden email]> wrote:
> On 31 Dec 2017, at 10:24 (-0500), Voytek wrote:
>> On Mon, January 1, 2018 1:19 am, Alex JOST wrote:
>>> Am 29.12.2017 um 21:15 schrieb Eero Volotinen:

>>>> A bit offtopic, but I need cli-tool to remove attachments from specific
>>>> maildir messages, so how to do that?

>>> The Thunderbird add-on 'AttachmentExtractor' should be able to do that,
>>> but I don't know if it still works with recent versions of Thunderbird as
>>> it hasn't been updated in a long time.

>>> As Bill already noted such operations should be considered wisely. Wrong
>>> manipulation of the message can make it unreadable. Backups are mandatory.

>> I'm happy to be corrected here, but, I'm fairly certain I have done so in
>> the past, with no ill effect, and, one can always copy the actual file to
>> a new file, anyhow.
>>
>> it was i think uudecode ? first for uuencoded emails, and, munpack for
>> mime encoded, something like 'munpack email_file':

> Yes, but that does not *remove* the attachments from the existing message file. It extracts decoded copies of the attachments. The original message file is unmodified.

I think using dovecot and sieve would be possible to do this, but as others have said this seems to be trying to solve the wrong problem.

If the attachments are not wanted, it seems unlikely the mail itself is wanted, better to reject.

--
Wally: That's my nickname, "Waly" with one el. Dilbert: Who calls you
that? Wally: Most people, they just don't realize it.

Reply | Threaded
Open this post in threaded view
|

Re: stupid question about removing maildir attachments

Maarten

Well attachments shouldn't be bigger than 50M anyways, 25M is already big. If you want to send files bigger than 50M you should look

another way to have users share files, like a file transer service.


On 12/31/2017 07:41 PM, Eero Volotinen wrote:
Well, case is that I want to migrate from postfix to google g-suite and they don't accept mails bigger than 50M. 

So, I need to strip and save old attachments and upload them to google drive. (stupid limit, but it exists without change to modify it)

Eero

Eero

31.12.2017 20.21 "@lbutlr" <[hidden email]> kirjoitti:
On 31 Dec 2017, at 09:43, Bill Cole <[hidden email]> wrote:
> On 31 Dec 2017, at 10:24 (-0500), Voytek wrote:
>> On Mon, January 1, 2018 1:19 am, Alex JOST wrote:
>>> Am 29.12.2017 um 21:15 schrieb Eero Volotinen:

>>>> A bit offtopic, but I need cli-tool to remove attachments from specific
>>>> maildir messages, so how to do that?

>>> The Thunderbird add-on 'AttachmentExtractor' should be able to do that,
>>> but I don't know if it still works with recent versions of Thunderbird as
>>> it hasn't been updated in a long time.

>>> As Bill already noted such operations should be considered wisely. Wrong
>>> manipulation of the message can make it unreadable. Backups are mandatory.

>> I'm happy to be corrected here, but, I'm fairly certain I have done so in
>> the past, with no ill effect, and, one can always copy the actual file to
>> a new file, anyhow.
>>
>> it was i think uudecode ? first for uuencoded emails, and, munpack for
>> mime encoded, something like 'munpack email_file':

> Yes, but that does not *remove* the attachments from the existing message file. It extracts decoded copies of the attachments. The original message file is unmodified.

I think using dovecot and sieve would be possible to do this, but as others have said this seems to be trying to solve the wrong problem.

If the attachments are not wanted, it seems unlikely the mail itself is wanted, better to reject.

--
Wally: That's my nickname, "Waly" with one el. Dilbert: Who calls you
that? Wally: Most people, they just don't realize it.


Reply | Threaded
Open this post in threaded view
|

Re: stupid question about removing maildir attachments

Eero Volotinen-2
Yes, I will ask them to use google drive in future, but I really need to transfer old attachments also. :)

Eero

31.12.2017 20.52 "Maarten" <[hidden email]> kirjoitti:

Well attachments shouldn't be bigger than 50M anyways, 25M is already big. If you want to send files bigger than 50M you should look

another way to have users share files, like a file transer service.


On 12/31/2017 07:41 PM, Eero Volotinen wrote:
Well, case is that I want to migrate from postfix to google g-suite and they don't accept mails bigger than 50M. 

So, I need to strip and save old attachments and upload them to google drive. (stupid limit, but it exists without change to modify it)

Eero

Eero

31.12.2017 20.21 "@lbutlr" <[hidden email]> kirjoitti:
On 31 Dec 2017, at 09:43, Bill Cole <[hidden email]> wrote:
> On 31 Dec 2017, at 10:24 (-0500), Voytek wrote:
>> On Mon, January 1, 2018 1:19 am, Alex JOST wrote:
>>> Am 29.12.2017 um 21:15 schrieb Eero Volotinen:

>>>> A bit offtopic, but I need cli-tool to remove attachments from specific
>>>> maildir messages, so how to do that?

>>> The Thunderbird add-on 'AttachmentExtractor' should be able to do that,
>>> but I don't know if it still works with recent versions of Thunderbird as
>>> it hasn't been updated in a long time.

>>> As Bill already noted such operations should be considered wisely. Wrong
>>> manipulation of the message can make it unreadable. Backups are mandatory.

>> I'm happy to be corrected here, but, I'm fairly certain I have done so in
>> the past, with no ill effect, and, one can always copy the actual file to
>> a new file, anyhow.
>>
>> it was i think uudecode ? first for uuencoded emails, and, munpack for
>> mime encoded, something like 'munpack email_file':

> Yes, but that does not *remove* the attachments from the existing message file. It extracts decoded copies of the attachments. The original message file is unmodified.

I think using dovecot and sieve would be possible to do this, but as others have said this seems to be trying to solve the wrong problem.

If the attachments are not wanted, it seems unlikely the mail itself is wanted, better to reject.

--
Wally: That's my nickname, "Waly" with one el. Dilbert: Who calls you
that? Wally: Most people, they just don't realize it.


Reply | Threaded
Open this post in threaded view
|

Re: stupid question about removing maildir attachments

Marat Khalili
> Yes, I will ask them to use google drive in future, but I really need to transfer old attachments also. :)

Your choice. When I faced same problem I just warned a handful affected users that some messages in their mailbox were oversized and thus not migrated, but they can receive them out-of-band if necessary. In the end, nobody asked, so I just deleted them eventually. Majority of these messages were Sent copies, with matching "unable to deliver, message too big" reports in Inbox.

Thunderbird integration with cloud services (e.g. Nextcloud) really helps here.
--

With Best Regards,
Marat Khalili
Reply | Threaded
Open this post in threaded view
|

Re: stupid question about removing maildir attachments

Bill Cole-3
In reply to this post by Alex JOST-2
On 31 Dec 2017, at 9:19 (-0500), Alex JOST wrote:

> Am 29.12.2017 um 21:15 schrieb Eero Volotinen:
>> Hi list,
>>
>> A bit offtopic, but I need cli-tool to remove attachments from
>> specific
>> maildir messages, so how to do that?
>
> The Thunderbird add-on 'AttachmentExtractor' should be able to do
> that, but I don't know if it still works with recent versions of
> Thunderbird as it hasn't been updated in a long time.

Also, using IMAP should be safe because it doesn't actually change
files. If that extension appears to remove the attachments from the
messages, it must be deleting the existing message and storing a new one
without the attachments. Message data (including headers and
attachments) in IMAP is immutable.

--
Bill Cole
[hidden email] or [hidden email]
(AKA @grumpybozo and many *@billmail.scconsult.com addresses)
Currently Seeking Steady Work: https://linkedin.com/in/billcole