Index: asterisk-1.4.17~dfsg/apps/app_voicemail.c =================================================================== --- asterisk-1.4.17~dfsg.orig/apps/app_voicemail.c 2009-01-30 07:01:41.000000000 +0100 +++ asterisk-1.4.17~dfsg/apps/app_voicemail.c 2009-01-30 15:45:07.000000000 +0100 @@ -317,6 +317,8 @@ char password[80]; /*!< Secret pin code, numbers only */ char fullname[80]; /*!< Full name, for directory app */ char email[80]; /*!< E-mail address */ + char *emailsubject; /*!< E-mail subject */ + char *emailbody; /*!< E-mail body */ char pager[80]; /*!< E-mail address to pager (no attachment) */ char serveremail[80]; /*!< From: Mail address */ char mailcmd[160]; /*!< Configurable mail command */ @@ -570,6 +572,8 @@ if (maxmsg) vmu->maxmsg = maxmsg; vmu->volgain = volgain; + vmu->emailsubject = NULL; + vmu->emailbody = NULL; } static void apply_option(struct ast_vm_user *vmu, const char *var, const char *value) @@ -689,6 +693,10 @@ ast_copy_string(retval->fullname, tmp->value, sizeof(retval->fullname)); } else if (!strcasecmp(tmp->name, "context")) { ast_copy_string(retval->context, tmp->value, sizeof(retval->context)); + } else if (!strcasecmp(tmp->name, "emailsubject") && tmp->value != NULL) { + retval->emailsubject = strdup(tmp->value); + } else if (!strcasecmp(tmp->name, "emailbody") && tmp->value != NULL) { + retval->emailbody = strdup(tmp->value); #ifdef IMAP_STORAGE } else if (!strcasecmp(tmp->name, "imapuser")) { ast_copy_string(retval->imapuser, tmp->value, sizeof(retval->imapuser)); @@ -1820,15 +1828,16 @@ len_passdata = strlen(vmu->fullname) * 2 + 3; passdata2 = alloca(len_passdata); fprintf(p, "To: %s <%s>" ENDL, quote(vmu->fullname, passdata2, len_passdata), vmu->email); - if (emailsubject) { + if (emailsubject || vmu->emailsubject) { + char *e_subj = vmu->emailsubject ? vmu->emailsubject : emailsubject; struct ast_channel *ast; if ((ast = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "", "", "", 0, 0))) { char *passdata; - int vmlen = strlen(emailsubject)*3 + 200; + int vmlen = strlen(e_subj)*3 + 200; if ((passdata = alloca(vmlen))) { memset(passdata, 0, vmlen); prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, cidnum, cidname, dur, date, passdata, vmlen, category); - pbx_substitute_variables_helper(ast, emailsubject, passdata, vmlen); + pbx_substitute_variables_helper(ast, e_subj, passdata, vmlen); fprintf(p, "Subject: %s" ENDL, passdata); } else ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n"); @@ -1874,15 +1883,16 @@ fprintf(p, "--%s" ENDL, bound); } fprintf(p, "Content-Type: text/plain; charset=%s" ENDL "Content-Transfer-Encoding: 8bit" ENDL ENDL, charset); - if (emailbody) { + if (emailbody || vmu->emailbody) { + char* e_body = vmu->emailbody ? vmu->emailbody : emailbody; struct ast_channel *ast; if ((ast = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "", "", "", 0, 0))) { char *passdata; - int vmlen = strlen(emailbody)*3 + 200; + int vmlen = strlen(e_body)*3 + 200; if ((passdata = alloca(vmlen))) { memset(passdata, 0, vmlen); prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, cidnum, cidname, dur, date, passdata, vmlen, category); - pbx_substitute_variables_helper(ast, emailbody, passdata, vmlen); + pbx_substitute_variables_helper(ast, e_body, passdata, vmlen); fprintf(p, "%s" ENDL, passdata); } else ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n"); @@ -2095,8 +2105,17 @@ static void free_user(struct ast_vm_user *vmu) { + if (vmu->emailbody != NULL) { + free(vmu->emailbody); + vmu->emailbody = NULL; + } + if (vmu->emailsubject != NULL) { + free(vmu->emailsubject); + vmu->emailsubject = NULL; + } if (ast_test_flag(vmu, VM_ALLOCED)) free(vmu); + } static void free_zone(struct vm_zone *z)