+# Creates voicemail config if installed and enabled.
+pbx_configure_voicemail()
+{
+ local enabled
+ local global_timeout
+ local global_email_addresses
+
+ local smtp_tls
+ local smtp_server
+ local smtp_port
+ local smtp_auth
+ local smtp_user
+ local smtp_password
+
+ config_get enabled global_voicemail enabled
+
+ # First check if voicemail is enabled.
+ [ "$enabled" != "yes" ] && exit
+
+ config_get global_timeout global_voicemail global_timeout
+ #config_get global_email_addresses global_voicemail global_email_addresses
+ config_get smtp_auth voicemail_smtp smtp_auth
+ config_get smtp_tls voicemail_smtp smtp_tls
+ config_get smtp_server voicemail_smtp smtp_server
+ config_get smtp_port voicemail_smtp smtp_port
+ config_get smtp_user voicemail_smtp smtp_user
+ config_get smtp_password voicemail_smtp smtp_password
+
+ sed "s/|AUTH|/$smtp_auth/" $TMPL_MSMTPDEFAULT |\
+ sed "s/|TLS|/$smtp_tls/" > $WORKDIR/pbx-msmtprc
+
+ sed "s/|HOST|/$smtp_server/" $TMPL_MSMTPACCOUNT |\
+ sed "s/|PORT|/$smtp_port/" >> $WORKDIR/pbx-msmtprc
+
+ if [ "$smtp_auth" = "on" ] ; then
+ sed "s/|USER|/$smtp_user/" $TMPL_MSMTPAUTH |\
+ sed "s/|PASSWORD|/$smtp_password/" >> $WORKDIR/pbx-msmtprc
+ fi
+
+ cat $TMPL_MSMTPACCTDFLT >> $WORKDIR/pbx-msmtprc
+
+ [ ! -f /etc/pbx-msmtprc ] && cp $WORKDIR/pbx-msmtprc /etc/pbx-msmtprc
+ diff -q $WORKDIR/pbx-msmtprc /etc/pbx-msmtprc 1>/dev/null \
+ || mv $WORKDIR/pbx-msmtprc /etc/pbx-msmtprc
+ chmod 600 /etc/pbx-msmtprc
+
+ # Copy over the extensions file which has voicemail enabled.
+ cp $TMPL_EXTVMENABLED $WORKDIR/extensions_voicemail.conf
+}
+
+