summaryrefslogtreecommitdiffabout
path: root/src/mail.c
authorSergey Poznyakoff <gray@gnu.org.ua>2009-12-06 10:20:08 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2009-12-06 10:20:08 (GMT)
commita1d560a878d1dfe4ed751cb3f99b1ee67755f489 (patch) (side-by-side diff)
tree0c7e45d5ba14c309fe67929245d8a75df6d3692a /src/mail.c
parent565650272f219fd372347f0ff3375b09caa18952 (diff)
downloadwydawca-a1d560a878d1dfe4ed751cb3f99b1ee67755f489.tar.gz
wydawca-a1d560a878d1dfe4ed751cb3f99b1ee67755f489.tar.bz2
Allow to specify arbitrary notification recipients.
* src/wydawca.h (enum notification_target): New value notify_read, meaning "read recipient addresses from the message headers". * src/config.c (target_args): New values: "read" and "message". (target_types): New value 'notify_read'. * src/mail.c (mail_send_message): Handle NULL rcpt. (do_notify): Handle notify_read.
Diffstat (limited to 'src/mail.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/mail.c57
1 files changed, 35 insertions, 22 deletions
diff --git a/src/mail.c b/src/mail.c
index a40e4b4..91ea502 100644
--- a/src/mail.c
+++ b/src/mail.c
@@ -64,22 +64,25 @@ mail_send_message (mu_address_t rcpt, const char *text)
mu_message_get_header (msg, &hdr);
mu_header_append (hdr, "X-Mailer", x_mailer);
- mu_address_to_string (rcpt, NULL, 0, &size);
- buf = xmalloc (size + 1);
- mu_address_to_string (rcpt, buf, size + 1, NULL);
-
- mu_header_set_value (hdr, "To", buf, 1);
- free (buf);
-
- if (from_address && mu_header_sget_value (hdr, "From", &sval))
+ if (rcpt)
{
- mu_address_to_string (from_address, NULL, 0, &size);
+ mu_address_to_string (rcpt, NULL, 0, &size);
buf = xmalloc (size + 1);
- mu_address_to_string (from_address, buf, size + 1, NULL);
- mu_header_set_value (hdr, "From", buf, 1);
+ mu_address_to_string (rcpt, buf, size + 1, NULL);
+
+ mu_header_set_value (hdr, "To", buf, 1);
free (buf);
- }
+ if (from_address && mu_header_sget_value (hdr, "From", &sval))
+ {
+ mu_address_to_string (from_address, NULL, 0, &size);
+ buf = xmalloc (size + 1);
+ mu_address_to_string (from_address, buf, size + 1, NULL);
+ mu_header_set_value (hdr, "From", buf, 1);
+ free (buf);
+ }
+ }
+
if (debug_level > 1)
{
mu_debug_t debug;
@@ -365,6 +368,10 @@ do_notify (struct file_triplet *trp, enum notification_event ev,
const char *errp;
switch (ntf->tgt)
{
+ case notify_read:
+ rcpt = NULL;
+ break;
+
case notify_admin:
rcpt = mu_address_dup (admin_address);
break;
@@ -378,7 +385,7 @@ do_notify (struct file_triplet *trp, enum notification_event ev,
trp, &errp);
}
- if (!rcpt)
+ if (!rcpt && ntf->tgt != notify_read)
{
logmsg (LOG_ERR, _("not notifying %s (project %s) about %s: %s"),
notification_target_str (ntf->tgt),
@@ -389,16 +396,22 @@ do_notify (struct file_triplet *trp, enum notification_event ev,
if (debug_level)
{
- size_t size;
- char *buf;
- mu_address_to_string (rcpt, NULL, 0, &size);
- buf = xmalloc (size + 1);
- mu_address_to_string (rcpt, buf, size + 1, NULL);
- logmsg (LOG_DEBUG, _("notifying %s (project %s) about %s"),
- buf, trp->project, notification_event_str (ev));
- free (buf);
+ if (rcpt)
+ {
+ size_t size;
+ char *buf;
+ mu_address_to_string (rcpt, NULL, 0, &size);
+ buf = xmalloc (size + 1);
+ mu_address_to_string (rcpt, buf, size + 1, NULL);
+ logmsg (LOG_DEBUG, _("notifying %s (project %s) about %s"),
+ buf, trp->project, notification_event_str (ev));
+ free (buf);
+ }
+ else
+ logmsg (LOG_DEBUG, _("notifying message recipients (project %s) about %s"),
+ trp->project, notification_event_str (ev));
}
-
+
if (!dry_run_mode)
{
const char *msg = resolve_message_template (ntf->msg);

Return to:

Send suggestions and report system problems to the System administrator.