Hi, Sergey,
I hope you don't mind my sending this directly, since it *is* unsolicited.
Here is my warmup 'use case' , to get a feel for GNU Mailutils, what
I've been working on, and I must say the software you've worked so hard
on has been a *big* help on this.
Use case: I like to read news on my (Android) phone, subcribe to a bunch
of feeds, but all the Android RSS feed readers I've found are too
graphics intensive, suck the battery dry, are slow because of all the
pictures they insist on downloading, limit the articles on hand, etc.,
etc., they just don't seem to be what I need.
On the other hand, Android has the K-9 Mail program which handles
folders just fine, has STARTTLS support,etc.
Then, after some googling, in the Debian repository on my server I find
RSS2Email, a cool little Python script that fetches RSS feed articles
and mails them using the local mailer. (FWIW, I liked and used Python
before I fell in love with Guile).
The articles pretty much always have a link to the original article, and
from K-9 I can tap the link and open it in the browser (And Firefox on
Android has Ad Block, just sayin' ;)
Fast, easy, works for me.
So, *lots* of incoming mails that need to be sorted into folders - GNU
Mailutils, maidag and Guile to the rescue!
Now I'm wondering if there might be a way to use Maidag in LMTP mode for
this, i.e., point RSS2Email at it somehow? Would that be possible? And
also have Maidag sort it into folders?
I've also attached a version of my Maidag delivery script. I've only
used it once so far, but it worked great. I'm thinking it could be
generalized a bit more, plus I need to wrap a 'catch' around
(mu-mailbox-append-message target-mailbox message)
because on 4 (out of 67) messages, it didn't work.
I'm wondering if maybe there is mailbox locking issue? What would happen if 2
different worker threads (am I guessing right here?) tried to access the same
mailbox at the same time? Because the mailbox names in the log file are just
fine, i.e., I have no idea why this is in syslog otherwise:
Jun 6 11:21:57 kaikala maidag[8600]: ERROR: Throw to key `mailutils-error'
with args `("mu-m\
ailbox-append-message" "Cannot append message ~A to mailbox ~A" (#<message
"chris@workingdroi\
d.com" "Wed Jun 6 06:21" 56 2546 > #<mailbox
mbox:///home/chris/mail/mailboxes/RSS/Atlantic\
/mBoX-mSgDaTa (0)>) (4106))'.
Jun 6 11:22:06 kaikala maidag[8810]: ERROR: Throw to key `mailutils-error'
with args `("mu-m\
ailbox-append-message" "Cannot append message ~A to mailbox ~A" (#<message
"chris@workingdroi\
d.com" "Wed Jun 6 06:22" 27 1276 > #<mailbox
mbox:///home/chris/mail/mailboxes/RSS/The Regi\
ster/mBoX-mSgDaTa (0)>) (4106))'
I've gotta hand it to you, Sergey: email systems, and *especially* the messages
that flow through them, are a *huge* challenge: well done!
Sincerely,
Chris
;;;; -*- scheme -*-
;;;; maidag-example.scm -- an example filter script for distributing
;;;; incoming mail
;;;;
;;;; Copyright (C) 2002-2004, 2006-2007, 2009-2012 Free Software
;;;; Foundation, Inc.
;;;;
;;;; maidag-example.scm is free software; you can redistribute it
;;;; and/or modify it under the terms of the GNU General Public
;;;; License as published by the Free Software Foundation; either
;;;; version 3, or (at your option) any later version.
;;;;
;;;; maidag-example.scm is distributed in the hope that it will be useful,
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;;; GNU General Public License for more details.
;;;;
;;;; For a copy of the GNU General Public License, see
;;;; <http://www.gnu.org/licenses/>.
;;;;
;;;; Load the GNU Mailutils library -- a must!
(use-modules (mailutils mailutils))
;;;; This script is meant to be called on a per-email basis from the
;;;; GNU Mailutils mail delivery agent program 'maidag'. This script
;;;; defines all the utility functions first -- the real work is done
;;;; in 'mailutils-check-message' at the end
(define (construct-folder-path sender-title)
"Insert a piece into a file path, the resulting path to the file is expected
to already exist on the file system, but the file itself needn't."
(if sender-title
(string-append "mbox:///home/chris/mail/mailboxes/" sender-title "/mBoX-MeSsAgEs")
#f))
;; An association list mapping incoming email 'From:' headers to a
;; piece of a file path
(define sender-folders
'(("Ars Technica <[email protected]>" . "RSS/ArsTechnica")
("\"Deutsche Welle: DW-WORLD.DE\" <[email protected]>" . "RSS/DWelle")
("\"Master Feed : The Atlantic\" <[email protected]>" . "RSS/Atlantic")
("" . "")
("" . "")))
(define (determine-target-folder message-from)
"Select a piece of a file path based on the incoming message's 'From:'
header"
(cond
;; These guys include the author's name in the From, so just check first bit
((string=? "\"The Register:" (substring message-from 0 14))
"RSS/The Register")
(else
(assoc-ref sender-folders message-from))))
(define (mailutils-check-message message)
"Here is where the work gets done. Based on the 'From:' header of the
incoming message, we try to build a file system path to a target
mailbox. If that succeeds, we try to open the file at the end of the
path, creating it if necessary. And if that succeeds, we try to
append the incoming message to it, and flag the message as 'deleted'."
(let* ((message-origin (mu-message-get-header message "From"))
(target-mailbox-name
(and message-origin (construct-folder-path (determine-target-folder message-origin)))))
(let ((target-mailbox
(and target-mailbox-name (mu-mailbox-open target-mailbox-name "cw"))))
(when target-mailbox
(mu-mailbox-append-message target-mailbox message)
(mu-mailbox-close target-mailbox)
(mu-message-delete message)))))
_______________________________________________
Bug-mailutils mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-mailutils