From da0ce17f15e3bb0d3b9eb1442f036d8f549ceee8 Mon Sep 17 00:00:00 2001 From: grunfink Date: Mon, 28 Apr 2025 05:15:31 +0200 Subject: Email notifications are sent the old way if 'spawn_sendmail' is set to true. --- activitypub.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/activitypub.c b/activitypub.c index fbf7a1f..92e408b 100644 --- a/activitypub.c +++ b/activitypub.c @@ -2570,6 +2570,34 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req) int send_email(const xs_dict *mailinfo) /* invoke curl */ { + if (xs_is_true(xs_dict_get(srv_config, "spawn_sendmail"))) { + const char *msg = xs_dict_get(mailinfo, "body"); + FILE *f; + int status; + int fds[2]; + pid_t pid; + + if (pipe(fds) == -1) return -1; + pid = vfork(); + if (pid == -1) return -1; + else if (pid == 0) { + dup2(fds[0], 0); + close(fds[0]); + close(fds[1]); + execl("/usr/sbin/sendmail", "sendmail", "-t", (char *) NULL); + _exit(1); + } + close(fds[0]); + if ((f = fdopen(fds[1], "w")) == NULL) { + close(fds[1]); + return -1; + } + fprintf(f, "%s\n", msg); + fclose(f); + if (waitpid(pid, &status, 0) == -1) return -1; + return status; + } + const char *url = xs_dict_get(srv_config, "smtp_url"), *user = xs_dict_get(srv_config, "smtp_username"), -- cgit v1.2.3