For the past year to 2 years, I have had this issue where asterisk would not send emails out when voicemails were left. The strange thing was that it only worked when I started asterisk manually from command line but it would not work correctly when run from any startup or boot script. After looking into the problem more deeply did I realize that esmtp does not run as root when called by asterisk unless asterisk was first started by root. The example below is the only way ive found to get asterisk to send emails without killing the application first and starting it manually through the console as a root user every time I rebooted the device.
In your voicemail.conf file use the line below to get asterisk to run esmtp as root even when started by a boot script. Be sure to replace the exact directory location of esmtp/sendmail with yours.
mailcmd=su -c “/opt/bin/esmtp -t -f your@email.com”
You could also replace the command with the sendmail equivalent since esmtp mimics sendmail to a certain degree. The command I listed isnt rocket science, but i just didnt know enough about linux to actually implement it correctly in the voicemail.conf file. Hopefully this helps someone figure out why asterisk will not send emails with the voicemail as an attachment unless run manually via command line and not by a boot script.
If asterisk does not send (voice-) mails with the given (and installed) MTA (exim sendmail etc) and even doesn’t fire up any notice/error/warning within CLI, than you might want to check permissions for the user running the PBX as daemon.
Let’s say the user running the PBX is named “asterisk” (standard), and your system provides a group for accessing Mail-Transfer-Agents, mostly defined as “mail”, than you probably just need to add the user “asterisk” to the group “mail”. “asterisk” as daemon user is limited, so that might be necessary.
You’d check the documentation of your system, how to to so.
I had that issue on a debian Linux right now, and fixed it by
“usermod -a -G mail asterisk” within a shell,
which added the user “asterisk” to the “mail” group. There are many way to do so.
For then asterisk itself started to queue the mails correctly by having
mailcmd=/usr/sbin/sendmail -t
in my case to /var/spool/exim4/input (exim is just linked to sendmail as an replacement)
After that I also had another configuration problem but with the exim MTA itself.
It didn’t like the remote mail-server…
Finally, if you do not receive e-mails from asterisk voicemailsystem, check out if the (voice)mails are queued within system path mostly something like
/var/spool/sendmail | exim4 | fooMTA/input
If the (human readable) mail files from asterisk are in there actually, you’ve got to take
care about your MTA’s configuration, otherwise the daemon user “asterisk” (or whoever it’s named on your system) just might have the indicated permission trouble.
BTW: “su -c” will mostly generate other problems on many systems, I recommend not to do so for security reasons.
asterisk=both thumbs up 🙂