Download raw body.
calendar(1): introduce RECIPIENT_EMAIL
On Sat, Feb 01, 2025 at 11:18:40PM +0100, Kirill A. Korinsky wrote:
> tech@
>
> Here a patch which introduced a special variable RECIPIENT_EMAIL in
> calendar(1).
>
> By default it sends daily emails to a user and it can be forwarded via
> ~/.forward to desire destination. But here no way to send calendar's email
> to other email.
>
> My patch introduced a variable RECIPIENT_EMAIL which can be used to override
> the destination email in calendar file.
>
> Feedback? Ok?
>
Do we need extra checks to be sure `recipient' contains valid email
address?
> Index: usr.bin/calendar/calendar.1
> ===================================================================
> RCS file: /home/cvs/src/usr.bin/calendar/calendar.1,v
> diff -u -p -r1.44 calendar.1
> --- usr.bin/calendar/calendar.1 29 Jan 2019 22:28:30 -0000 1.44
> +++ usr.bin/calendar/calendar.1 1 Feb 2025 22:03:35 -0000
> @@ -107,6 +107,10 @@ Use
> .Dq CALENDAR=
> to return to the default (Gregorian).
> .Pp
> +The
> +.Dq RECIPIENT_EMAIL
> +variable can be used to specify recipient of daily mails.
> +.Pp
> To enforce special date calculation mode for Cyrillic calendars
> you should specify
> .Dq LANG=<local_name>
> Index: usr.bin/calendar/io.c
> ===================================================================
> RCS file: /home/cvs/src/usr.bin/calendar/io.c,v
> diff -u -p -r1.51 io.c
> --- usr.bin/calendar/io.c 7 Dec 2021 14:00:33 -0000 1.51
> +++ usr.bin/calendar/io.c 31 Jan 2025 01:01:38 -0000
> @@ -51,6 +51,9 @@
> #include "calendar.h"
>
>
> +char *recipient = NULL;
> +
> +
> struct iovec header[] = {
> { "From: ", 6 },
> { NULL, 0 },
> @@ -123,6 +126,11 @@ cal(void)
> if ((prefix = strdup(buf + 6)) == NULL)
> err(1, NULL);
> continue;
> + } else if (strncmp(buf, "RECIPIENT_EMAIL=", 16) == 0) {
> + free(recipient);
> + if ((recipient = strdup(buf + 16)) == NULL)
> + err(1, NULL);
> + continue;
> }
> /* User defined names for special events */
> if ((p = strchr(buf, '='))) {
> @@ -408,7 +416,7 @@ closecal(FILE *fp)
> }
> (void)close(pdes[1]);
> execl(_PATH_SENDMAIL, "sendmail", "-i", "-t", "-F",
> - "\"Reminder Service\"", (char *)NULL);
> + "\"Reminder Service\"", recipient, (char *)NULL);
> warn(_PATH_SENDMAIL);
> _exit(1);
> }
>
>
> --
> wbr, Kirill
>
calendar(1): introduce RECIPIENT_EMAIL