diff --git a/Makefile.am b/Makefile.am index e0a2c59acd..1f57471748 100644 --- a/Makefile.am +++ b/Makefile.am @@ -160,7 +160,7 @@ install-data-local: @for x in conf conf/dialplan conf/directory conf/sip_profiles mod db log log/xml_cdr bin scripts htdocs grammar ; do \ $(mkinstalldirs) $(DESTDIR)$(prefix)/$$x ; \ done - for conffile in `find conf -name \*.xml && find conf -name \*.conf && find conf -name mime.types` ; do \ + for conffile in `find conf -name \*.xml && find conf -name \*.conf && find conf -name \*.tpl && find conf -name mime.types` ; do \ dir=`echo $$conffile | sed -e 's|/[^/]*$$||'`; \ filename=`echo $$conffile | sed -e 's|^.*/||'`; \ test -d $(DESTDIR)$(PREFIX)/$$dir || $(mkinstalldirs) $(DESTDIR)$(prefix)/$$dir ; \ diff --git a/conf/autoload_configs/voicemail.conf.xml b/conf/autoload_configs/voicemail.conf.xml index 06ca4c8bff..59a238181a 100644 --- a/conf/autoload_configs/voicemail.conf.xml +++ b/conf/autoload_configs/voicemail.conf.xml @@ -39,16 +39,8 @@ - - -To: <${voicemail_email}> -Subject: ${voicemail_message_len} sec Voicemail from ${voicemail_caller_id_name} ${voicemail_caller_id_number} -X-Priority: ${voicemail_priority} -X-Mailer: FreeSWITCH -]]> - + + diff --git a/conf/voicemail.tpl b/conf/voicemail.tpl new file mode 100644 index 0000000000..8061f0b1e3 --- /dev/null +++ b/conf/voicemail.tpl @@ -0,0 +1,11 @@ +From: FreeSWITCH mod_voicemail <${voicemail_account}@${voicemail_domain}> +To: <${voicemail_email}> +Subject: ${voicemail_message_len} sec Voicemail from ${voicemail_caller_id_name} ${voicemail_caller_id_number} +X-Priority: ${voicemail_priority} +X-Mailer: FreeSWITCH + +At ${voicemail_time} you were left a ${voicemail_message_len} second message from ${voicemail_caller_id_name} ${voicemail_caller_id_number} +to your account ${voicemail_account}@${voicemail_domain} + + + diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c index 26262ed9bc..65d3244654 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.c +++ b/src/mod/applications/mod_voicemail/mod_voicemail.c @@ -330,6 +330,39 @@ static switch_status_t load_config(void) date_fmt = val; } else if (!strcasecmp(var, "email-from") && !switch_strlen_zero(val)) { email_from = val; + } else if (!strcasecmp(var, "template-file") && !switch_strlen_zero(val)) { + switch_stream_handle_t stream = { 0 }; + int fd; + char *dpath = NULL; + char *path; + + if (switch_is_file_path(val)) { + path = val; + } else { + dpath = switch_mprintf("%s%s%s", + SWITCH_GLOBAL_dirs.conf_dir, + SWITCH_PATH_SEPARATOR, + val); + path = dpath; + } + + if ((fd = open(path, O_RDONLY)) > -1) { + char buf[2048]; + SWITCH_STANDARD_STREAM(stream); + while(switch_fd_read_line(fd, buf, sizeof(buf))) { + stream.write_function(&stream, "%s", buf); + } + close(fd); + email_headers = stream.data; + if ((email_body = strstr(email_headers, "\n\n"))) { + *email_body = '\0'; + email_body += 2; + } else if ((email_body = strstr(email_headers, "\r\n\r\n"))) { + *email_body = '\0'; + email_body += 4; + } + } + switch_safe_free(dpath); } } }