[Dovecot] manipulating mails
Hi all,
sorry for my inexperience. I am still learning. I searched for a while but found nothing useful. I am looking for the best way to manipulate headers, bodies, attachments, locations, folders and/or flags while using deliver and e.g. perl. In other words manipulating the whole mail in respect of the requirements of the LDA, MUA and User. I see two diffent ways.
As i understand I can work via IMAP and pre-auth sessions, which keeps track of the index files from dovecot and handles complications with users already logged in. Can I use e.g. some perl imap module -> download the mail -> change it -> upload it again with all other parameters unchanged and no confusions on the user's side? This way I think its complex to rewrite the mail header/body/attachments as desired and keep everything else, eg times, flags, headers. the goal should be close to invisibility for a user. This maybe leads to open pre-authed sockets/ports and a lot of work.
The other way would be to directly modify the file system. This keeps everything (i think), but changes mtime and needs some index file and MUA cache update. For performance reasons I would like to not use the index-automatism of dovecot but do it manualy at runtime of some script. How does the index update gets initialized from the outside? Same for the client cache. Is there some command available or is a IMAP login my workaround? This maybe leads to password problems or open pre-authed sockets/ports.
Last question: Is it possible to add some received-tag to a mail-header when appending mails via imap to the mailbox?
Can anyone turn my head in the desired direction? Thanks in advance Sven
my thought would be: make it like amavis ...
- your mta forwards you the mail via smtp.
- you munch the email (although i seriously wonder why)
- you send it back to your mta via smtp
- mta calls dovecot to deliver the mail
for better suggestions, it would be nice to know what kind of modifications you want to do.
-- openSUSE - SUSE Linux is my linux openSUSE is good for you www.opensuse.org
Marcus Rueckert schrieb:
my thought would be: make it like amavis ...
- your mta forwards you the mail via smtp.
- you munch the email (although i seriously wonder why)
- you send it back to your mta via smtp
- mta calls dovecot to deliver the mail
for better suggestions, it would be nice to know what kind of modifications you want to do.
for the moment i want to delete mails from dovecots maildir. but i am looking for a general way for automate mail processing with perl. not shure yet to what this will lead sven
On 2010-04-15 19:01:39 +0200, Sven wrote:
Marcus Rueckert schrieb:
my thought would be: make it like amavis ...
- your mta forwards you the mail via smtp.
- you munch the email (although i seriously wonder why)
- you send it back to your mta via smtp
- mta calls dovecot to deliver the mail
for better suggestions, it would be nice to know what kind of modifications you want to do.
for the moment i want to delete mails from dovecots maildir. but i am looking for a general way for automate mail processing with perl. not shure yet to what this will lead sven
uhm ... you should be a bit more specific ... deleting mails could mean "all mails older than" there the expire tool could help you.
in general i would use imap to delete mails, as you are independent of the used storage.
darix
-- openSUSE - SUSE Linux is my linux openSUSE is good for you www.opensuse.org
Marcus Rueckert schrieb:
On 2010-04-15 19:01:39 +0200, Sven wrote:
Marcus Rueckert schrieb:
my thought would be: make it like amavis ...
- your mta forwards you the mail via smtp.
- you munch the email (although i seriously wonder why)
- you send it back to your mta via smtp
- mta calls dovecot to deliver the mail
for better suggestions, it would be nice to know what kind of modifications you want to do.
for the moment i want to delete mails from dovecots maildir. but i am looking for a general way for automate mail processing with perl. not shure yet to what this will lead sven
uhm ... you should be a bit more specific ... deleting mails could mean "all mails older than" there the expire tool could help you.
in general i would use imap to delete mails, as you are independent of the used storage.
darix
i want to move mails from some specific imap folder to some other folder on the filesystem to precess them further more. but maybe i want to copy the mail and then set the seen flag. i think both can be done via imap, but maybe i want to add some tag/keyword, text or attachment from some processing skript with processing informations thinks getting more complex ... sven
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Thu, 15 Apr 2010, Sven wrote:
i want to move mails from some specific imap folder to some other folder on the filesystem to precess them further more. but maybe i want to copy the mail and then set the seen flag. i think both can be done via imap, but maybe i want to add some tag/keyword, text or attachment from some processing skript with processing informations thinks getting more complex ...
In IMAP storage messages are immutable, per spec. That means: You cannot transparently change the content of a message, e.g. add/remove headers or (parts of) the body, once the message has been delivered.
If you do it the IMAP way, each manipulated messages (I mean the content, not the keywords/tags/flags) becomes a new message, hence, the clients might download it again.
If you keep that in mind, you can successfully manipulate the content of messages in Maildir by:
- rename message somewhere else,
- manipulate it
- rename it to maildir_mailbox/tmp
- adjust access permissions
- rename it to maildir_mailbox/new or ../cur making sure the file gets a new filename stem (part of filename before the
colon) than it had originally.
If a new file pops up in cur/new, Dovecot assumes a non-Dovecot delivery and re-indexes the file next time the user accesses the mailbox.
To manipulate the flags I would use PREAUTH.
You can savly remove files from a Maildir.
Regards,
Steffen Kaiser -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux)
iQEVAwUBS8gbtL+Vh58GPL/cAQL5TQf+KOzTvYLPiTLSitOhd4IOawjb9B9+U/Fe jHi4XpgGk4ubs22CQ7yUD6v2ozzRMjqIKDPFvvBvJfRW84G1zB3aj2p6lE0QN7XP ekWhuVkUHSbKwPCcxXvZAXTBv8/nPD45+mz32JyqHVZA/2QG0FDayM6d4mUg29AR EdGxNXd/1SzO12xHAqe+kG3EzhUTY5p3U1/Bfg8YlXutUyIQ+qK9rrEPsuLfWDOy ZdnKCohvR13lq92MJiXosuN56kC8kGsSHj/YVhsdIhNpDP61YE2uuRqJtxd8Ynpu 3VnLFZHIg1dv4GDFgaZP6ul3e7YShVZUgAyZLxCiglL6rBqk3KKnFw== =mG0U -----END PGP SIGNATURE-----
Thanks a lot, Steffen. Sounds like some work. Catch your free beer(s) if you touch Frankfurt. Sven
Steffen Kaiser schrieb:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Thu, 15 Apr 2010, Sven wrote:
i want to move mails from some specific imap folder to some other folder on the filesystem to precess them further more. but maybe i want to copy the mail and then set the seen flag. i think both can be done via imap, but maybe i want to add some tag/keyword, text or attachment from some processing skript with processing informations thinks getting more complex ...
In IMAP storage messages are immutable, per spec. That means: You cannot transparently change the content of a message, e.g. add/remove headers or (parts of) the body, once the message has been delivered.
If you do it the IMAP way, each manipulated messages (I mean the content, not the keywords/tags/flags) becomes a new message, hence, the clients might download it again.
If you keep that in mind, you can successfully manipulate the content of messages in Maildir by:
- rename message somewhere else,
- manipulate it
- rename it to maildir_mailbox/tmp
- adjust access permissions
- rename it to maildir_mailbox/new or ../cur making sure the file gets a new filename stem (part of filename before the colon) than it had originally.
If a new file pops up in cur/new, Dovecot assumes a non-Dovecot delivery and re-indexes the file next time the user accesses the mailbox.
To manipulate the flags I would use PREAUTH.
You can savly remove files from a Maildir.
Regards,
- -- Steffen Kaiser -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux)
iQEVAwUBS8gbtL+Vh58GPL/cAQL5TQf+KOzTvYLPiTLSitOhd4IOawjb9B9+U/Fe jHi4XpgGk4ubs22CQ7yUD6v2ozzRMjqIKDPFvvBvJfRW84G1zB3aj2p6lE0QN7XP ekWhuVkUHSbKwPCcxXvZAXTBv8/nPD45+mz32JyqHVZA/2QG0FDayM6d4mUg29AR EdGxNXd/1SzO12xHAqe+kG3EzhUTY5p3U1/Bfg8YlXutUyIQ+qK9rrEPsuLfWDOy ZdnKCohvR13lq92MJiXosuN56kC8kGsSHj/YVhsdIhNpDP61YE2uuRqJtxd8Ynpu 3VnLFZHIg1dv4GDFgaZP6ul3e7YShVZUgAyZLxCiglL6rBqk3KKnFw== =mG0U -----END PGP SIGNATURE-----
participants (3)
-
Marcus Rueckert
-
Steffen Kaiser
-
Sven