mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-20 08:40:16 +00:00
Add pager stuff
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@829 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -391,6 +391,45 @@ static int sendmail(char *srcemail, char *email, char *name, int msgnum, char *m
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int sendpage(char *srcemail, char *pager, int msgnum, char *mailbox, char *callerid, long duration)
|
||||||
|
{
|
||||||
|
FILE *p;
|
||||||
|
char date[256];
|
||||||
|
char host[256];
|
||||||
|
char who[256];
|
||||||
|
char dur[256];
|
||||||
|
time_t t;
|
||||||
|
struct tm tm;
|
||||||
|
struct ast_config *cfg;
|
||||||
|
p = popen(SENDMAIL, "w");
|
||||||
|
cfg = ast_load(VOICEMAIL_CONFIG);
|
||||||
|
|
||||||
|
if (p) {
|
||||||
|
gethostname(host, sizeof(host));
|
||||||
|
if (strchr(srcemail, '@'))
|
||||||
|
strncpy(who, srcemail, sizeof(who)-1);
|
||||||
|
else {
|
||||||
|
snprintf(who, sizeof(who), "%s@%s", srcemail, host);
|
||||||
|
}
|
||||||
|
snprintf(dur, sizeof(dur), "%ld:%02ld", duration / 60, duration % 60);
|
||||||
|
time(&t);
|
||||||
|
localtime_r(&t,&tm);
|
||||||
|
strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", &tm);
|
||||||
|
fprintf(p, "Date: %s\n", date);
|
||||||
|
fprintf(p, "From: Asterisk PBX <%s>\n", who);
|
||||||
|
fprintf(p, "To: %s\n", pager);
|
||||||
|
fprintf(p, "Subject: New voicemail\n\n");
|
||||||
|
strftime(date, sizeof(date), "%A, %B %d, %Y at %r", &tm);
|
||||||
|
fprintf(p, "New %s long message in mailbox %s\n"
|
||||||
|
"from %s, on %s", dur, mailbox, (callerid ? callerid : "unknown"), date);
|
||||||
|
pclose(p);
|
||||||
|
} else {
|
||||||
|
ast_log(LOG_WARNING, "Unable to launch '%s'\n", SENDMAIL);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int get_date(char *s, int len)
|
static int get_date(char *s, int len)
|
||||||
{
|
{
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
@@ -436,7 +475,7 @@ static int invent_message(struct ast_channel *chan, char *ext, int busy, char *e
|
|||||||
static int leave_voicemail(struct ast_channel *chan, char *ext, int silent, int busy, int unavail)
|
static int leave_voicemail(struct ast_channel *chan, char *ext, int silent, int busy, int unavail)
|
||||||
{
|
{
|
||||||
struct ast_config *cfg;
|
struct ast_config *cfg;
|
||||||
char *copy, *name, *passwd, *email, *fmt, *fmts;
|
char *copy, *name, *passwd, *email, *pager, *fmt, *fmts;
|
||||||
char comment[256];
|
char comment[256];
|
||||||
struct ast_filestream *writer=NULL, *others[MAX_OTHER_FORMATS];
|
struct ast_filestream *writer=NULL, *others[MAX_OTHER_FORMATS];
|
||||||
char *sfmt[MAX_OTHER_FORMATS];
|
char *sfmt[MAX_OTHER_FORMATS];
|
||||||
@@ -485,6 +524,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, int silent, int
|
|||||||
passwd = strsep(&stringp, ",");
|
passwd = strsep(&stringp, ",");
|
||||||
name = strsep(&stringp, ",");
|
name = strsep(&stringp, ",");
|
||||||
email = strsep(&stringp, ",");
|
email = strsep(&stringp, ",");
|
||||||
|
pager = strsep(&stringp, ",");
|
||||||
make_dir(dir, sizeof(dir), ext, "");
|
make_dir(dir, sizeof(dir), ext, "");
|
||||||
/* It's easier just to try to make it than to check for its existence */
|
/* It's easier just to try to make it than to check for its existence */
|
||||||
if (mkdir(dir, 0700) && (errno != EEXIST))
|
if (mkdir(dir, 0700) && (errno != EEXIST))
|
||||||
@@ -712,6 +752,8 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, int silent, int
|
|||||||
/* Send e-mail if applicable */
|
/* Send e-mail if applicable */
|
||||||
if (email)
|
if (email)
|
||||||
sendmail(astemail, email, name, msgnum, ext, chan->callerid, fn, wavother ? "wav" : fmts, end - start);
|
sendmail(astemail, email, name, msgnum, ext, chan->callerid, fn, wavother ? "wav" : fmts, end - start);
|
||||||
|
if (pager)
|
||||||
|
sendpage(astemail, pager, msgnum, ext, chan->callerid, end - start);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (msgnum < MAXMSG)
|
if (msgnum < MAXMSG)
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ attach=yes
|
|||||||
skipms=3000
|
skipms=3000
|
||||||
|
|
||||||
;
|
;
|
||||||
; Each mailbox is listed in the form <mailbox>=<password>,<name>,<email>
|
; Each mailbox is listed in the form <mailbox>=<password>,<name>,<email>,<pager_email>
|
||||||
; if the e-mail is specified, a message will be sent when a message is
|
; if the e-mail is specified, a message will be sent when a message is
|
||||||
; received, to the given mailbox.
|
; received, to the given mailbox. If pager is specified, a message will be sent there as well.
|
||||||
;
|
;
|
||||||
[default]
|
[default]
|
||||||
1234 => 4242,Example Mailbox,root@localhost
|
1234 => 4242,Example Mailbox,root@localhost
|
||||||
|
|||||||
Reference in New Issue
Block a user