Summary:ASTERISK-14207: VOICEMAIL : I've tried a lot but mailing is not working...
Reporter:Jonas Kellens (jonaskellens)Labels:
Date Opened:2009-05-26 13:24:33Date Closed:2011-06-07 14:08:12
Versions:Frequency of
Description:What do I want :

When a voicemail-message is left via the Voicemail()-application, I want the .wav-file send to my mail-address as an attachment.
(the great feature of Comedian Mail compared to proprietary solutions!)

My mail-setup :

I'm not using sendmail as MTA. I have msmtp as MTA and mutt as MUA.
Mailing with mutt and msmtp works well. I have a crontab running that sends me every Saturday my Asterisk logfiles like this :

mutt -s "LOGFILE verbose $DATUM" -a /var/log/asterisk/verbose jonas.kellens@telenet.be < /dev/null
mutt -s "LOGFILE debug $DATUM" -a /var/log/asterisk/debug jonas.kellens@telenet.be < /dev/null

My /root/.msmtprc-file has the following :

# Set default values for all following accounts.
logfile ~/.msmtp.log

# The SMTP server of the provider.
account default
host uit.telenet.be
user my_username
password my_password
from jonas.kellens@telenet.be

The logfile of msmtp (/root/.msmtp.log) shows a successful sending :

May 23 03:01:30 host=uit.telenet.be tls=off auth=off from=jonas.kellens@telenet.be recipients=jonas.kellens@telenet.be mailsize=197590 smtpstatus=250 smtpms
g='250 2.0.0 Message accepted for delivery (sR311b0033o2nLm0HR31q7)' exitcode=EX_OK
(this was last sunday morning at 3 am)

Msmtp vs Sendmail

I have made a symbolic link from sendmail to msmtp :
[root@asterisk asterisk]# ls -l /usr/sbin/sendmail
lrwxrwxrwx 1 root root 20 May 17 21:10 /usr/sbin/sendmail -> /usr/local/bin/msmtp

When I use the default setting in voicemail.conf (mailcmd=/usr/sbin/sendmail -v -t -f), then msmtp will be used. I hoped...


emailsubject=[PBX]: New message ${VM_MSGNUM} in mailbox ${VM_MAILBOX}
emailbody=Dear ${VM_NAME}:\n\n\tjust wanted to let you know you were just left a ${VM_DUR} long message (number ${VM_MSGNUM})\nin mailbox ${VM_MAILBOX} from ${VM_CALLERID}, on ${VM_DATE}, so you might\nwant to check it when you get a chance. Thanks!\n\n\t\t\t\t--Asterisk\n
emaildateformat=%A, %B %d, %Y at %r

mailcmd=/usr/sbin/sendmail -v -t -f

european=Europe/Copenhagen|'vm-received' a d b 'digits/at' HM
belgie=Europe/Brussels|'vm-received' Q 'digits/at' R

60 => 4569,Jonas Kellens,jonas.kellens@telenet.be

In my extensions.conf I has the following :

exten => 2000,1,Voicemail(60@voicemail-context,u)

Now, which settings have I tried :

voicemail.conf :

serveremail=Asterisk PBX

mailcmd=/usr/sbin/sendmail -v -t -f
mailcmd=/usr/local/bin/msmtp -v -t -f
mailcmd=/usr/local/bin/mutt -v -f -a
mailcmd=/usr/sbin/sendmail -v -t -f jonas.kellens@telenet.be
mailcmd=/usr/local/bin/msmtp -v -t -f jonas.kellens@telenet.be

Logfile msmtp :

Whenever I call extension 2000, I get the voicemail. I leave a message. There is no fault on the Asterisk CLI.
There is NO entry in the logfile of msmtp (/root/.msmtp.log). No error, no success.

I have the impression that Asterisk is unable to communicate with sendmail or msmtp...

Let's try something different :

So if Asterisk does not want to send mail, I can maybe write a dialplan that checks for messages and sends the voicemailmessages to my mailaddress.

So I have the following :
[root@asterisk agi-bin]# ls -l /var/lib/asterisk/agi-bin/mail2.sh
-rwxr-xr-x 1 root root 58 May 21 15:16 /var/lib/asterisk/agi-bin/mail2.sh
[root@asterisk agi-bin]# cat /var/lib/asterisk/agi-bin/mail2.sh
mutt -s "$1" -a "$2" jonas.kellens@telenet.be < /dev/null

and this in my dialplan :

exten => 3000,1,NoOp(test mailscript)
exten => 3000,n,System(/var/lib/asterisk/agi-bin/mail2.sh test-email /etc/asterisk/iax.conf)
exten => 3000,n,NoOp(systemstatus : ${SYSTEMSTATUS})

But this does not work according to the output on the CLI :

-- Executing [3000@TCS-personeel-zoiper:1] NoOp("IAX2/jonaskellens-10491", "test mailscript") in new stack
-- Executing [3000@TCS-personeel-zoiper:2] System("IAX2/jonaskellens-10491", "/var/lib/asterisk/agi-bin/mail2.sh test-email /etc/asterisk/iax.conf") in new stack
-- Executing [3000@TCS-personeel-zoiper:3] NoOp("IAX2/jonaskellens-10491", "systemstatus : APPERROR") in new stack

So I'm stuck

There is no way for me to get my voicemail-messages through mailing... and I absolutely want to implement this.
Comments:By: Russell Bryant (russell) 2009-05-26 16:31:27

Please use the forums or mailing lists for support.

By: Jonas Kellens (jonaskellens) 2009-05-28 01:27:26

Sorry if re-opening this issue makes me a bad person, but I have posted this issue @ the mailinglist, and after that @ the digium forum, and now I thought I'd ask the developers ...

This problem I have with Asterisk sending me my voicemail-messages is still not resolved.

To others, who have the same implementation with msmtp, it seems to go smoothly. They even define no "mailcmd=" in their voicemail.conf and Asterisk automatically takes the configured SMTP-mail-server on the system.

This is not the case with my Asterisk-server.

So I was wondering, if I execute Asterisk as root-user, why can Asterisk not talk to msmtp ?

In fact, how does the message look like that Asterisk produces ??
So I know which arguments I need to use with the msmtp-command. Like "-a" for adding an attachment...

I was hoping to get to know something about the rights that Asterisk needs to be able to send mail ?! And the mail that it produces when a voicemail-message has been left...

Asterisk works best with which MTA ??