On Wed, Jun 22, 2005 at 01:54:41PM +0300, Sergey Poznyakoff wrote:
>
> Kalimera, Kosta! Nice to have you with us.
>
Now, that's a very worm welcome!
> > The loop goes OK, printing the from and subject headers for each
> > message, but I get the string
> >
> > fileinto: cannot save to mailbox: Function not implemented
> >
> > for each message that matches the script's criteria. Do I need to
> > register my own handler function for the fileinto action anywere?
>
> No, but you do need to register at least one *mailbox format* handler.
> You can do this using mu_register_all_formats(). This macro registers
> handlers for all mailbox and mailer formats supported by mailutils.
> Alternatively, you may use one of the following macros:
>
> mu_register_local_mbox_formats() Registers only local formats,
> i.e. mbox,mh,maildir
> mu_register_remote_mbox_formats() Registers only remote mailbox formats,
> i.e. pop and imap
>
> or register the desired mailbox formats manually, e.g. like this:
>
> list_t rl;
> registrar_get_list (&rl);
> list_append (rl, path_record);
> list_append (rl, mbox_record);
>
Thanks a lot for this, but I have done it already using the macro
mu_register_local_mbox_formats(). I had to dig for a bit to find this
out and finally I saw the macro at register.h.
Please find attached my program (it's only ~100 lines) and my filter
script (filters.sieve)
I call this program as
./testsieve file://path/to/Maildir filters.sieve
and in the output I get
...
Elisa Shirley" <[EMAIL PROTECTED]> [Possible SPAM] Qualities Pharrmacy
JWVh8
lottery dayzers <[EMAIL PROTECTED]> [Possible SPAM] WINNING AWARD NOTIFICATION
!!!
Sergey Poznyakoff <[EMAIL PROTECTED]> Re: [bug-mailutils] [Error] fileinto:
cannot save to mailbox: Function not implemented
fileinto: cannot save to mailbox: Function not implemented
...
I also get a zero length file test.mbox created but no mail is
delivered there.
Any other suggestions are highly welcome.
Thanks for your answer.
> Regards,
> Sergey
>
Regards,
Kostas
--
Kostas Zorbadelos
Systems Designer/Developer, Otenet SA
[EMAIL PROTECTED] contact: kzorba (at) otenet.gr
Out there in the darkness, out there in the night
out there in the starlight, one soul burns brighter
than a thousand suns.
/*------------------------------------------------------------------
* testsieve.c
* This program tests the functionality of the mailutils libraries,
* specifically libmailbox and libsieve.
*
* The program expects as input a mailbox location and a file containing
* a sieve script. It reads and runs the sieve script for each message of
* the mailbox in turn.
------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <mailutils/mailutils.h>
int main(int argc, char* argv[]) {
char *from;
char *subject;
mailbox_t mbox;
size_t msgno, total = 0;
int status;
sieve_machine_t mach;
/* Register the formats. */
/* This supports mbox, maildir and mh */
mu_register_local_mbox_formats();
/* mu_register_all_mbox_formats (); */
/* Create the instance of the sieve machine */
status = sieve_machine_init(&mach,NULL);
if (status !=0) {
mu_error ("Cannot initialize sieve machine: %s", mu_strerror (status));
exit (EXIT_FAILURE);;
}
status = sieve_compile(mach,argv[2]);
if (status !=0) {
mu_error ("Error compile sieve script: %s", mu_strerror (status));
exit (EXIT_FAILURE);;
}
status = mailbox_create(&mbox, argv[1]);
if (status != 0) {
mu_error ("mailbox_create: %s", mu_strerror (status));
exit (EXIT_FAILURE);
}
status = mailbox_open(mbox, MU_STREAM_READ);
if (status != 0) {
mu_error ("mailbox_open: %s", mu_strerror (status));
exit (EXIT_FAILURE);
}
mailbox_messages_count (mbox, &total);
for (msgno = 1; msgno <= total; msgno++) {
message_t msg;
header_t hdr;
if ((status = mailbox_get_message (mbox, msgno, &msg)) != 0
|| (status = message_get_header (msg, &hdr)) != 0) {
mu_error ("Error message: %s", mu_strerror (status));
exit (EXIT_FAILURE);
}
if (header_aget_value (hdr, MU_HEADER_FROM, &from))
from = strdup ("(NO FROM)");
if (header_aget_value (hdr, MU_HEADER_SUBJECT, &subject))
subject = strdup ("(NO SUBJECT)");
printf ("%s\t%s\n", from, subject);
free (from);
free (subject);
status = sieve_message(mach,msg);
if (status != 0)
mu_error ("Error sieve_message: %s", mu_strerror (status));
}
status = mailbox_close (mbox);
if (status != 0) {
mu_error ("mailbox_close: %s", mu_strerror (status));
exit (EXIT_FAILURE);
}
sieve_machine_destroy(&mach);
mailbox_destroy (&mbox);
return 0;
}
require "fileinto";
if header :contains "from" "Sergey"
{
fileinto "test.mbox";
}
_______________________________________________
Bug-mailutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-mailutils