diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-01-27 00:37:47 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-01-27 00:37:47 +0000 |
commit | 516e279643c5c069a1ed58801152ffbb203141d1 (patch) | |
tree | e8b923fc7136146e1f40361adeb9655fc92ebbf7 | |
parent | 8cd1350b5622a7c2bf850153967f2b7246b9e187 (diff) |
Character set fixes, and add "mailcmd" option (bug #472)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@2082 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-x | apps/app_voicemail.c | 33 | ||||
-rwxr-xr-x | configs/voicemail.conf.sample | 5 |
2 files changed, 31 insertions, 7 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 9b36e195a..612cf9400 100755 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -67,6 +67,8 @@ static inline void sql_close(void) { } #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" @@ -91,6 +93,7 @@ struct baseio { unsigned char iobuf[BASEMAXINLINE]; }; +/* Structure for linked list of users */ struct ast_vm_user { char context[80]; char mailbox[80]; @@ -99,6 +102,7 @@ struct ast_vm_user { char email[80]; char pager[80]; char serveremail[80]; + char mailcmd[160]; /* Configurable mail command */ char zonetag[80]; int attach; int alloced; @@ -183,6 +187,8 @@ static int attach_voicemail; 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; @@ -194,6 +200,7 @@ static int pbxskip = 0; static char fromstring[100]; static char emailtitle[100]; + STANDARD_LOCAL_USER; LOCAL_USER_DECL; @@ -382,6 +389,7 @@ static void reset_user_pw(char *context, char *mailbox, char *password) #endif /* Postgres */ #ifndef USESQLVM + static struct ast_vm_user *find_user(struct ast_vm_user *ivm, char *context, char *mailbox) { /* This function could be made to generate one from a database, too */ @@ -675,7 +683,7 @@ static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *m 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, '@')) @@ -733,7 +741,7 @@ static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *m fprintf(p, "--%s\n", bound); } - fprintf(p, "Content-Type: TEXT/PLAIN; charset=US-ASCII\n\n"); + fprintf(p, "Content-Type: text/plain; charset=ISO-8859-1\nContent-Transfer-Encoding: 8bit\n"); strftime(date, sizeof(date), "%A, %B %d, %Y at %r", &tm); if (emailbody) { struct ast_channel *ast = ast_channel_alloc(0); @@ -764,7 +772,7 @@ static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *m if (attach_user_voicemail) { fprintf(p, "--%s\n", bound); fprintf(p, "Content-Type: audio/x-%s; name=\"msg%04d.%s\"\n", format, msgnum, format); - fprintf(p, "Content-Transfer-Encoding: BASE64\n"); + fprintf(p, "Content-Transfer-Encoding: base64\n"); fprintf(p, "Content-Description: Voicemail sound attachment.\n"); fprintf(p, "Content-Disposition: attachment; filename=\"msg%04d.%s\"\n\n", msgnum, format); @@ -773,8 +781,9 @@ static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *m 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; @@ -790,7 +799,7 @@ static int sendpage(char *srcemail, char *pager, int msgnum, char *mailbox, char 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)); @@ -830,8 +839,9 @@ static int sendpage(char *srcemail, char *pager, int msgnum, char *mailbox, char 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; @@ -3145,6 +3155,7 @@ static int load_config(void) char *thresholdstr; char *fmt; char *astemail; + char *astmailcmd = SENDMAIL; char *s; int x; @@ -3168,10 +3179,18 @@ static int load_config(void) 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); @@ -3179,6 +3198,8 @@ static int load_config(void) maxsilence *= 1000; } + + /* Silence treshold */ silencethreshold = 256; if ((thresholdstr = ast_variable_retrieve(cfg, "general", "silencethreshold"))) silencethreshold = atoi(thresholdstr); diff --git a/configs/voicemail.conf.sample b/configs/voicemail.conf.sample index 11ff91d60..50281e398 100755 --- a/configs/voicemail.conf.sample +++ b/configs/voicemail.conf.sample @@ -30,7 +30,10 @@ maxlogins=3 ; Change the email body, variables: VM_NAME, VM_DUR, VM_MSGNUM, VM_MAILBOX, VM_CALLERID, VM_DATE ;emailbody=Dear ${VM_NAME}:\n\n\tjust wanted to let you know you were just left a ${VM_DUR} long message (number ${VM_MSGNUM})\nin mailbox ${VM_MAILBOX} from ${VM_CALLERID}, on ${VM_DATE} so you might\nwant to check it when you get a chance. Thanks!\n\n\t\t\t\t--Asterisk\n - +; +; You can override the default program to send e-mail if you wish, too +; +;mailcmd=/usr/sbin/sendmail -t ; ; Users may be located in different timezones, or may have different ; message announcements for their introductory message when they enter |