From 7e9bfa63f0ceac1f35dba231c314ad85f2f3a53c Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Fri, 15 Jan 2021 11:10:48 +0100 Subject: [PATCH] bsmtp: Add the possibility to add emails separated with a comma as recipient list --- bacula/src/tools/bsmtp.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/bacula/src/tools/bsmtp.c b/bacula/src/tools/bsmtp.c index d1c5ecbdb..4a5aade93 100644 --- a/bacula/src/tools/bsmtp.c +++ b/bacula/src/tools/bsmtp.c @@ -589,8 +589,21 @@ lookup_host: chat("MAIL FROM:%s\r\n", cleanup_addr(from_addr, buf, sizeof(buf))); for (i = 0; i < argc; i++) { - Dmsg1(20, "rcpt to: %s\n", argv[i]); - chat("RCPT TO:%s\r\n", cleanup_addr(argv[i], buf, sizeof(buf))); + char *m = argv[i]; + if (m) { + /* email1,email2,email3 */ + for (char *end = strchr(m, ','); end ; end = strchr(m, ',')) { + *end = 0; + Dmsg1(20, "rcpt to: %s\n", argv[i]); + chat("RCPT TO:%s\r\n", cleanup_addr(m, buf, sizeof(buf))); + m = end+1; // Move forward + *end = ','; // Get the original string back + } + if (*m) { // We should have a last one + Dmsg1(20, "rcpt to: %s\n", argv[i]); + chat("RCPT TO:%s\r\n", cleanup_addr(m, buf, sizeof(buf))); + } + } } if (cc_addr) { -- 2.47.3