--- app_voicemail.c.orig 2004-03-28 16:25:51.000000000 +0100 +++ app_voicemail.c 2004-03-29 00:17:14.000000000 +0100 @@ -210,6 +210,7 @@ static char *emailbody = NULL; static int pbxskip = 0; +static char *emailsubject = NULL; static char fromstring[100]; static char emailtitle[100]; @@ -766,6 +767,26 @@ fprintf(p, "From: Asterisk PBX <%s>\n", who); fprintf(p, "To: %s <%s>\n", vmu->fullname, vmu->email); + if (emailsubject) { + struct ast_channel *ast = ast_channel_alloc(0); + if (ast) { + char *passdata; + int vmlen = strlen(emailsubject)*3 + 200; + if ((passdata = alloca(vmlen))) { + memset(passdata, 0, vmlen); + pbx_builtin_setvar_helper(ast, "VM_NAME", vmu->fullname); + pbx_builtin_setvar_helper(ast, "VM_DUR", dur); + sprintf(passdata,"%d",msgnum + 1); + pbx_builtin_setvar_helper(ast, "VM_MSGNUM", passdata); + pbx_builtin_setvar_helper(ast, "VM_MAILBOX", mailbox); + pbx_builtin_setvar_helper(ast, "VM_CALLERID", (callerid ? callerid : "an unknown caller")); + pbx_builtin_setvar_helper(ast, "VM_DATE", date); + pbx_substitute_variables_helper(ast,emailsubject,passdata,vmlen); + fprintf(p, "Subject: %s\n",passdata); + } else ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n"); + ast_channel_free(ast); + } else ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n"); + } else if( *emailtitle) { fprintf(p, emailtitle, msgnum, mailbox) ; @@ -776,6 +797,7 @@ fprintf(p, "Subject: New message %d in mailbox %s\n", msgnum + 1, mailbox); else fprintf(p, "Subject: [PBX]: New message %d in mailbox %s\n", msgnum + 1, mailbox); + fprintf(p, "Message-ID: \n", msgnum, mailbox, getpid(), host); fprintf(p, "MIME-Version: 1.0\n"); if (attach_user_voicemail) { @@ -797,7 +819,7 @@ memset(passdata, 0, vmlen); pbx_builtin_setvar_helper(ast, "VM_NAME", vmu->fullname); pbx_builtin_setvar_helper(ast, "VM_DUR", dur); - sprintf(passdata,"%d",msgnum); + sprintf(passdata,"%d",msgnum + 1); pbx_builtin_setvar_helper(ast, "VM_MSGNUM", passdata); pbx_builtin_setvar_helper(ast, "VM_MAILBOX", mailbox); pbx_builtin_setvar_helper(ast, "VM_CALLERID", (callerid ? callerid : "an unknown caller")); @@ -3454,12 +3476,18 @@ free(emailbody); emailbody = NULL; } + if (emailsubject) { + free(emailsubject); + emailsubject = NULL; + } if ((s=ast_variable_retrieve(cfg, "general", "pbxskip"))) pbxskip = ast_true(s); if ((s=ast_variable_retrieve(cfg, "general", "fromstring"))) strncpy(fromstring,s,sizeof(fromstring)-1); if ((s=ast_variable_retrieve(cfg, "general", "emailtitle"))) strncpy(emailtitle,s,sizeof(emailtitle)-1); + if ((s=ast_variable_retrieve(cfg, "general", "emailsubject"))) + emailsubject = strdup(s); if ((s=ast_variable_retrieve(cfg, "general", "emailbody"))) { char *tmpread, *tmpwrite; emailbody = strdup(s);