summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2003-02-22 22:25:19 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2003-02-22 22:25:19 +0000
commite7730fe57706ff1369892883141b696b292ad353 (patch)
tree672902c12d8caf79cfcd79f4d97b56df7467855b
parent5ea83ef7082d3fa68e639ee343f7dba5fd1604c4 (diff)
downloadmailutils-e7730fe57706ff1369892883141b696b292ad353.tar.gz
mailutils-e7730fe57706ff1369892883141b696b292ad353.tar.bz2
Handle Fcc headers.
-rw-r--r--mailbox/mailer.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/mailbox/mailer.c b/mailbox/mailer.c
index 303c93e96..7331814b3 100644
--- a/mailbox/mailer.c
+++ b/mailbox/mailer.c
@@ -34,6 +34,9 @@
#include <mailutils/registrar.h>
#include <mailutils/stream.h>
#include <mailutils/url.h>
+#include <mailutils/header.h>
+#include <mailutils/mailbox.h>
+#include <mailutils/message.h>
#include <mailer0.h>
@@ -259,8 +262,45 @@ mailer_check_to (address_t to)
return 0;
}
+static void
+save_fcc (message_t msg)
+{
+ header_t hdr;
+ size_t count = 0, i;
+ char buf[512];
+
+ if (message_get_header (msg, &hdr))
+ return;
+
+ if (header_get_value (hdr, MU_HEADER_FCC, NULL, 0, NULL))
+ return;
+
+ header_get_field_count (hdr, &count);
+ for (i = 1; i <= count; i++)
+ {
+ mailbox_t mbox;
+
+ header_get_field_name (hdr, i, buf, sizeof buf, NULL);
+ if (strcasecmp (buf, MU_HEADER_FCC) == 0)
+ {
+ if (header_get_field_value (hdr, i, buf, sizeof buf, NULL))
+ continue;
+ if (mailbox_create_default (&mbox, buf))
+ continue; /*FIXME: error message?? */
+ if (mailbox_open (mbox, MU_STREAM_RDWR|MU_STREAM_CREAT|MU_STREAM_APPEND) == 0)
+ {
+ mailbox_append_message (mbox, msg);
+ mailbox_flush (mbox, 0);
+ }
+ mailbox_close (mbox);
+ mailbox_destroy (&mbox);
+ }
+ }
+}
+
int
-mailer_send_message (mailer_t mailer, message_t msg, address_t from, address_t to)
+mailer_send_message (mailer_t mailer, message_t msg,
+ address_t from, address_t to)
{
int status;
@@ -282,7 +322,8 @@ mailer_send_message (mailer_t mailer, message_t msg, address_t from, address_t t
if ((status = mailer_check_to (to)) != 0)
return status;
}
-
+
+ save_fcc (msg);
return mailer->_send_message (mailer, msg, from, to);
}

Return to:

Send suggestions and report system problems to the System administrator.