summaryrefslogtreecommitdiffstats
path: root/net/asterisk/patches/202-VM_MESSAGEFILE.patch
blob: b8b9e83e080853147c378fb4b03847421ff050e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
From e8b2e65d2130c5b1841dc4a456bfb79aa017a37e Mon Sep 17 00:00:00 2001
From: Andre Heider <a.heider@gmail.com>
Date: Wed, 21 Jan 2026 10:28:50 +0100
Subject: [PATCH] VM_MESSAGEFILE

---
 apps/app_voicemail.c | 8 ++++++++
 1 file changed, 8 insertions(+)

--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -5889,6 +5889,7 @@ static int sendmail(char *srcemail,
 	char tmp[80] = "/tmp/astmail-XXXXXX";
 	char tmp2[256];
 	char *stringp;
+	char fname[PATH_MAX] = "";
 
 	if (vmu && ast_strlen_zero(vmu->email)) {
 		ast_log(AST_LOG_WARNING, "E-mail address missing for mailbox [%s].  E-mail will not be sent.\n", vmu->mailbox);
@@ -5912,7 +5913,14 @@ static int sendmail(char *srcemail,
 		make_email_file(p, srcemail, vmu, msgnum, context, mailbox, fromfolder, cidnum, cidname, attach, attach2, format, duration, attach_user_voicemail, chan, category, 0, flag, msg_id);
 		fclose(p);
 		snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp);
+		if (ast_strlen_zero(attach)) {
+			unsetenv("VM_MESSAGEFILE");
+		} else {
+			snprintf(fname, sizeof(fname), "%s.%s", attach, format);
+			setenv("VM_MESSAGEFILE", fname, 1);
+		}
 		ast_safe_system(tmp2);
+		unsetenv("VM_MESSAGEFILE");
 		ast_debug(1, "Sent mail to %s with command '%s'\n", vmu->email, mailcmd);
 	}
 	return 0;