mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-20 12:20:12 +00:00
Character set fixes, and add "mailcmd" option (bug #472)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2082 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -67,6 +67,8 @@ static inline void sql_close(void) { }
|
|||||||
#define VOICEMAIL_CONFIG "voicemail.conf"
|
#define VOICEMAIL_CONFIG "voicemail.conf"
|
||||||
#define ASTERISK_USERNAME "asterisk"
|
#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 SENDMAIL "/usr/sbin/sendmail -t"
|
||||||
|
|
||||||
#define INTRO "vm-intro"
|
#define INTRO "vm-intro"
|
||||||
@@ -91,6 +93,7 @@ struct baseio {
|
|||||||
unsigned char iobuf[BASEMAXINLINE];
|
unsigned char iobuf[BASEMAXINLINE];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Structure for linked list of users */
|
||||||
struct ast_vm_user {
|
struct ast_vm_user {
|
||||||
char context[80];
|
char context[80];
|
||||||
char mailbox[80];
|
char mailbox[80];
|
||||||
@@ -99,6 +102,7 @@ struct ast_vm_user {
|
|||||||
char email[80];
|
char email[80];
|
||||||
char pager[80];
|
char pager[80];
|
||||||
char serveremail[80];
|
char serveremail[80];
|
||||||
|
char mailcmd[160]; /* Configurable mail command */
|
||||||
char zonetag[80];
|
char zonetag[80];
|
||||||
int attach;
|
int attach;
|
||||||
int alloced;
|
int alloced;
|
||||||
@@ -183,6 +187,8 @@ static int attach_voicemail;
|
|||||||
static int maxsilence;
|
static int maxsilence;
|
||||||
static int silencethreshold = 128;
|
static int silencethreshold = 128;
|
||||||
static char serveremail[80];
|
static char serveremail[80];
|
||||||
|
static char mailcmd[160]; /* Configurable mail cmd */
|
||||||
|
|
||||||
static char vmfmts[80];
|
static char vmfmts[80];
|
||||||
static int vmmaxmessage;
|
static int vmmaxmessage;
|
||||||
static int maxgreet;
|
static int maxgreet;
|
||||||
@@ -194,6 +200,7 @@ static int pbxskip = 0;
|
|||||||
static char fromstring[100];
|
static char fromstring[100];
|
||||||
static char emailtitle[100];
|
static char emailtitle[100];
|
||||||
|
|
||||||
|
|
||||||
STANDARD_LOCAL_USER;
|
STANDARD_LOCAL_USER;
|
||||||
|
|
||||||
LOCAL_USER_DECL;
|
LOCAL_USER_DECL;
|
||||||
@@ -382,6 +389,7 @@ static void reset_user_pw(char *context, char *mailbox, char *password)
|
|||||||
#endif /* Postgres */
|
#endif /* Postgres */
|
||||||
|
|
||||||
#ifndef USESQLVM
|
#ifndef USESQLVM
|
||||||
|
|
||||||
static struct ast_vm_user *find_user(struct ast_vm_user *ivm, char *context, char *mailbox)
|
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 */
|
/* 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"))
|
if (!strcmp(format, "wav49"))
|
||||||
format = "WAV";
|
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);
|
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) {
|
if (p) {
|
||||||
gethostname(host, sizeof(host));
|
gethostname(host, sizeof(host));
|
||||||
if (strchr(srcemail, '@'))
|
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, "--%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);
|
strftime(date, sizeof(date), "%A, %B %d, %Y at %r", &tm);
|
||||||
if (emailbody) {
|
if (emailbody) {
|
||||||
struct ast_channel *ast = ast_channel_alloc(0);
|
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) {
|
if (attach_user_voicemail) {
|
||||||
fprintf(p, "--%s\n", bound);
|
fprintf(p, "--%s\n", bound);
|
||||||
fprintf(p, "Content-Type: audio/x-%s; name=\"msg%04d.%s\"\n", format, msgnum, format);
|
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-Description: Voicemail sound attachment.\n");
|
||||||
fprintf(p, "Content-Disposition: attachment; filename=\"msg%04d.%s\"\n\n", msgnum, format);
|
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);
|
fprintf(p, "\n\n--%s--\n.\n", bound);
|
||||||
}
|
}
|
||||||
pclose(p);
|
pclose(p);
|
||||||
|
ast_log(LOG_DEBUG, "Sent mail to %s with command '%s'\n", who, mailcmd);
|
||||||
} else {
|
} else {
|
||||||
ast_log(LOG_WARNING, "Unable to launch '%s'\n", SENDMAIL);
|
ast_log(LOG_WARNING, "Unable to launch '%s'\n", mailcmd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -790,7 +799,7 @@ static int sendpage(char *srcemail, char *pager, int msgnum, char *mailbox, char
|
|||||||
time_t t;
|
time_t t;
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
struct vm_zone *the_zone = NULL;
|
struct vm_zone *the_zone = NULL;
|
||||||
p = popen(SENDMAIL, "w");
|
p = popen(mailcmd, "w");
|
||||||
|
|
||||||
if (p) {
|
if (p) {
|
||||||
gethostname(host, sizeof(host));
|
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"
|
fprintf(p, "New %s long msg in box %s\n"
|
||||||
"from %s, on %s", dur, mailbox, (callerid ? callerid : "unknown"), date);
|
"from %s, on %s", dur, mailbox, (callerid ? callerid : "unknown"), date);
|
||||||
pclose(p);
|
pclose(p);
|
||||||
|
ast_log(LOG_DEBUG, "Sent mail to %s with command '%s'\n", who, mailcmd);
|
||||||
} else {
|
} else {
|
||||||
ast_log(LOG_WARNING, "Unable to launch '%s'\n", SENDMAIL);
|
ast_log(LOG_WARNING, "Unable to launch '%s'\n", mailcmd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -3145,6 +3155,7 @@ static int load_config(void)
|
|||||||
char *thresholdstr;
|
char *thresholdstr;
|
||||||
char *fmt;
|
char *fmt;
|
||||||
char *astemail;
|
char *astemail;
|
||||||
|
char *astmailcmd = SENDMAIL;
|
||||||
char *s;
|
char *s;
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
@@ -3168,10 +3179,18 @@ static int load_config(void)
|
|||||||
usersl = NULL;
|
usersl = NULL;
|
||||||
if (cfg) {
|
if (cfg) {
|
||||||
/* General settings */
|
/* General settings */
|
||||||
|
|
||||||
|
/* Attach voice message to mail message ? */
|
||||||
attach_voicemail = 1;
|
attach_voicemail = 1;
|
||||||
if (!(astattach = ast_variable_retrieve(cfg, "general", "attach")))
|
if (!(astattach = ast_variable_retrieve(cfg, "general", "attach")))
|
||||||
astattach = "yes";
|
astattach = "yes";
|
||||||
attach_voicemail = ast_true(astattach);
|
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;
|
maxsilence = 0;
|
||||||
if ((silencestr = ast_variable_retrieve(cfg, "general", "maxsilence"))) {
|
if ((silencestr = ast_variable_retrieve(cfg, "general", "maxsilence"))) {
|
||||||
maxsilence = atoi(silencestr);
|
maxsilence = atoi(silencestr);
|
||||||
@@ -3179,6 +3198,8 @@ static int load_config(void)
|
|||||||
maxsilence *= 1000;
|
maxsilence *= 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Silence treshold */
|
||||||
silencethreshold = 256;
|
silencethreshold = 256;
|
||||||
if ((thresholdstr = ast_variable_retrieve(cfg, "general", "silencethreshold")))
|
if ((thresholdstr = ast_variable_retrieve(cfg, "general", "silencethreshold")))
|
||||||
silencethreshold = atoi(thresholdstr);
|
silencethreshold = atoi(thresholdstr);
|
||||||
|
@@ -30,7 +30,10 @@ maxlogins=3
|
|||||||
; Change the email body, variables: VM_NAME, VM_DUR, VM_MSGNUM, VM_MAILBOX, VM_CALLERID, VM_DATE
|
; 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
|
;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
|
; Users may be located in different timezones, or may have different
|
||||||
; message announcements for their introductory message when they enter
|
; message announcements for their introductory message when they enter
|
||||||
|
Reference in New Issue
Block a user