aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgrunfink <grunfink@comam.es>2025-04-28 05:15:31 +0200
committergrunfink <grunfink@comam.es>2025-04-28 05:15:31 +0200
commitda0ce17f15e3bb0d3b9eb1442f036d8f549ceee8 (patch)
tree3a580db39ea0bdfe3f183f06e361f0e6d639fe5b
parent2a353d2ffdd7a6235a8f1a04ef62bde77141f159 (diff)
Email notifications are sent the old way if 'spawn_sendmail' is set to true.
-rw-r--r--activitypub.c28
1 files changed, 28 insertions, 0 deletions
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"),