commit da0ce17f15e3bb0d3b9eb1442f036d8f549ceee8
parent 2a353d2ffdd7a6235a8f1a04ef62bde77141f159
Author: grunfink <grunfink@comam.es>
Date: Mon, 28 Apr 2025 05:15:31 +0200
Email notifications are sent the old way if 'spawn_sendmail' is set to true.
Diffstat:
1 file changed, 28 insertions(+), 0 deletions(-)
diff --git 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"),