Tag Archives: root

Asterisk and esmtp (or sendmail) not sending voicemail emails unless first run manually from console

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.