--- app_voicemail.c.org Mon Dec 29 22:41:18 2003 +++ app_voicemail.c Mon Dec 29 22:52:30 2003 @@ -64,6 +64,8 @@ #define VOICEMAIL_CONFIG "voicemail.conf" #define ASTERISK_USERNAME "asterisk" +/* Default mail command to mail voicemail. Change it with the + mailcmd= command in voicemail.conf */ #define SENDMAIL "/usr/sbin/sendmail -t" #define INTRO "vm-intro" @@ -96,6 +98,7 @@ char email[80]; char pager[80]; char serveremail[80]; + char mailcmd[160]; /* Configurable mail command */ char zonetag[80]; int attach; int alloced; @@ -180,6 +183,8 @@ static int maxsilence; static int silencethreshold = 128; static char serveremail[80]; +static char mailcmd[160]; /* Configurable mail cmd */ + static char vmfmts[80]; static int vmmaxmessage; static int maxgreet; @@ -191,6 +196,7 @@ static char fromstring[100]; static char emailtitle[100]; + STANDARD_LOCAL_USER; LOCAL_USER_DECL; @@ -676,7 +682,7 @@ if (!strcmp(format, "wav49")) format = "WAV"; ast_log(LOG_DEBUG, "Attaching file '%s', format '%s', uservm is '%d', global is %d\n", attach, format, attach_user_voicemail, attach_voicemail); - p = popen(SENDMAIL, "w"); + p = popen(mailcmd, "w"); if (p) { gethostname(host, sizeof(host)); if (strchr(srcemail, '@')) @@ -774,8 +780,9 @@ fprintf(p, "\n\n--%s--\n.\n", bound); } pclose(p); + ast_log(LOG_DEBUG, "Sent mail to %s with command '%s'\n", who, mailcmd); } else { - ast_log(LOG_WARNING, "Unable to launch '%s'\n", SENDMAIL); + ast_log(LOG_WARNING, "Unable to launch '%s'\n", mailcmd); return -1; } return 0; @@ -791,7 +798,7 @@ time_t t; struct tm tm; struct vm_zone *the_zone = NULL; - p = popen(SENDMAIL, "w"); + p = popen(mailcmd, "w"); if (p) { gethostname(host, sizeof(host)); @@ -831,8 +838,9 @@ fprintf(p, "New %s long msg in box %s\n" "from %s, on %s", dur, mailbox, (callerid ? callerid : "unknown"), date); pclose(p); + ast_log(LOG_DEBUG, "Sent mail to %s with command '%s'\n", who, mailcmd); } else { - ast_log(LOG_WARNING, "Unable to launch '%s'\n", SENDMAIL); + ast_log(LOG_WARNING, "Unable to launch '%s'\n", mailcmd); return -1; } return 0; @@ -3019,6 +3027,7 @@ char *thresholdstr; char *fmt; char *astemail; + char *astmailcmd = SENDMAIL; char *s; int x; @@ -3042,10 +3051,18 @@ usersl = NULL; if (cfg) { /* General settings */ + + /* Attach voice message to mail message ? */ attach_voicemail = 1; if (!(astattach = ast_variable_retrieve(cfg, "general", "attach"))) astattach = "yes"; attach_voicemail = ast_true(astattach); + + /* Mail command */ + strncpy(mailcmd, SENDMAIL, sizeof(mailcmd) - 1); /* Default */ + if ((astmailcmd = ast_variable_retrieve(cfg, "general", "mailcmd"))) + strncpy(mailcmd, astmailcmd, sizeof(mailcmd) - 1); /* User setting */ + maxsilence = 0; if ((silencestr = ast_variable_retrieve(cfg, "general", "maxsilence"))) { maxsilence = atoi(silencestr); @@ -3053,6 +3070,8 @@ maxsilence *= 1000; } + + /* Silence treshold */ silencethreshold = 256; if ((thresholdstr = ast_variable_retrieve(cfg, "general", "silencethreshold"))) silencethreshold = atoi(thresholdstr);