@ -570,6 +570,7 @@ static AST_LIST_HEAD_STATIC(vmstates, vmstate);
# define VM_MOVEHEARD (1 << 16) /*!< Move a "heard" message to Old after listening to it */
# define VM_MOVEHEARD (1 << 16) /*!< Move a "heard" message to Old after listening to it */
# define VM_MESSAGEWRAP (1 << 17) /*!< Wrap around from the last message to the first, and vice-versa */
# define VM_MESSAGEWRAP (1 << 17) /*!< Wrap around from the last message to the first, and vice-versa */
# define VM_FWDURGAUTO (1 << 18) /*!< Autoset of Urgent flag on forwarded Urgent messages set globally */
# define VM_FWDURGAUTO (1 << 18) /*!< Autoset of Urgent flag on forwarded Urgent messages set globally */
# define VM_EMAIL_EXT_RECS (1 << 19) /*!< Send voicemail emails when an external recording is added to a mailbox */
# define ERROR_LOCK_PATH -100
# define ERROR_LOCK_PATH -100
# define ERROR_MAX_MSGS -101
# define ERROR_MAX_MSGS -101
# define OPERATOR_EXIT 300
# define OPERATOR_EXIT 300
@ -1258,6 +1259,8 @@ static void apply_option(struct ast_vm_user *vmu, const char *var, const char *v
ast_set2_flag ( vmu , ast_true ( value ) , VM_ATTACH ) ;
ast_set2_flag ( vmu , ast_true ( value ) , VM_ATTACH ) ;
} else if ( ! strcasecmp ( var , " attachfmt " ) ) {
} else if ( ! strcasecmp ( var , " attachfmt " ) ) {
ast_copy_string ( vmu - > attachfmt , value , sizeof ( vmu - > attachfmt ) ) ;
ast_copy_string ( vmu - > attachfmt , value , sizeof ( vmu - > attachfmt ) ) ;
} else if ( ! strcasecmp ( var , " attachextrecs " ) ) {
ast_set2_flag ( vmu , ast_true ( value ) , VM_EMAIL_EXT_RECS ) ;
} else if ( ! strcasecmp ( var , " serveremail " ) ) {
} else if ( ! strcasecmp ( var , " serveremail " ) ) {
ast_copy_string ( vmu - > serveremail , value , sizeof ( vmu - > serveremail ) ) ;
ast_copy_string ( vmu - > serveremail , value , sizeof ( vmu - > serveremail ) ) ;
} else if ( ! strcasecmp ( var , " fromstring " ) ) {
} else if ( ! strcasecmp ( var , " fromstring " ) ) {
@ -6418,6 +6421,12 @@ static int msg_create_from_file(struct ast_vm_recording_data *recdata)
* to do both with one line and is also safe to use with file storage mode . Also , if we are using ODBC , now is a good
* to do both with one line and is also safe to use with file storage mode . Also , if we are using ODBC , now is a good
* time to create the voicemail database entry . */
* time to create the voicemail database entry . */
if ( ast_fileexists ( destination , NULL , NULL ) > 0 ) {
if ( ast_fileexists ( destination , NULL , NULL ) > 0 ) {
struct ast_channel * chan = NULL ;
char fmt [ 80 ] ;
char clid [ 80 ] ;
char cidnum [ 80 ] , cidname [ 80 ] ;
int send_email ;
if ( ast_check_realtime ( " voicemail_data " ) ) {
if ( ast_check_realtime ( " voicemail_data " ) ) {
get_date ( date , sizeof ( date ) ) ;
get_date ( date , sizeof ( date ) ) ;
ast_store_realtime ( " voicemail_data " ,
ast_store_realtime ( " voicemail_data " ,
@ -6437,7 +6446,27 @@ static int msg_create_from_file(struct ast_vm_recording_data *recdata)
}
}
STORE ( dir , recipient - > mailbox , recipient - > context , msgnum , NULL , recipient , fmt , 0 , vms , " " , msg_id ) ;
STORE ( dir , recipient - > mailbox , recipient - > context , msgnum , NULL , recipient , fmt , 0 , vms , " " , msg_id ) ;
notify_new_state ( recipient ) ;
send_email = ast_test_flag ( recipient , VM_EMAIL_EXT_RECS ) ;
if ( send_email ) {
/* Send an email if possible, fall back to just notifications if not. */
ast_copy_string ( fmt , recdata - > recording_ext , sizeof ( fmt ) ) ;
ast_copy_string ( clid , recdata - > call_callerid , sizeof ( clid ) ) ;
ast_callerid_split ( clid , cidname , sizeof ( cidname ) , cidnum , sizeof ( cidnum ) ) ;
/* recdata->call_callerchan itself no longer exists, so we can't use the real channel. Use a dummy one. */
chan = ast_dummy_channel_alloc ( ) ;
}
if ( chan ) {
notify_new_message ( chan , recipient , NULL , msgnum , duration , fmt , cidnum , cidname , " " ) ;
ast_channel_unref ( chan ) ;
} else {
if ( send_email ) { /* We tried and failed. */
ast_log ( LOG_WARNING , " Failed to allocate dummy channel, email will not be sent \n " ) ;
}
notify_new_state ( recipient ) ;
}
}
}
free_user ( recipient ) ;
free_user ( recipient ) ;