Check For The Voicemail

Home » Asterisk Users » Check For The Voicemail
Asterisk Users 17 Comments

Hi all, I have a problem with voicemail. My boss has asked me to send via email, the message that a user leaves on the voicemail. This is very easy. 🙂
After, he asked me to check before sending the email, if the receiver’s mailbox is full. If the mailbox is full, Asterisk should call the receveir intern (example 2001) and using a Playback tell him that his mailbox is full. How can I do? 🙁


17 thoughts on - Check For The Voicemail

  • Assuming that you are using the standard 100 message limit, just check for INBOX/MSG0100.txt and send the message.

    —–Original Message—

  • just another thought: if you send the message by mail, do you need to save it?

    regards, Ruben

    Am 21.08.2012 18:45, schrieb Danny Nicholas:

  • I’m sorry, I haven’t been clear. I do not have to check the inbox on Asterisk, but I have to check the free space on a particular mailbox of Exchange software. It’s possible with the pair Asterisk-Sendmail?

    Il 21/08/12 18:45, Danny Nicholas ha scritto:

  • The message must be deleted if sent to the recipient, otherwise it must remain on the Asterisk machine when the recipient’s mailbox is full. Il 21/08/12 18:52, Ruben R

  • I’ll explain. I have an email account, danilo.dionisi @, with a maximum size of 100MB. For example, my inbox is full, and Paris Hilton
    ( =P ) leaves me a voicemail message. I have to check the space of my inbox, this space is completely full, so I do not have to delete the voicemail message but I have to call my SIPphone and via a Playback announce that my inbox is full.

    Il 21/08/12 18:55, Carlos Rojas ha scritto:

  • I’m sorry, how i can to check for the return code of the smtp session?
    I’ve never done :p Thanks, Danilo

    Il 21/08/12 19:05, Ruben R

  • Okay, so have a look at “mailcmd=” option in voicemail.conf

    “mailbox” will mean a “e-mail-box” in the next lines.

    What you need to do is wirting a shell script or what ever to check for the return code of the smtp session (normally it should be a 450 in case of full mailbox). In case of “450 mailbox full” whatsoever you need to create a call file in /var/spool/asterisk/outgoing directing your recipient phone to a special extension which handles the playback of the “your mailbox is full” message.

    But: this will only work if you deliver the mail directly to the recipients mail server, if you use a smart host, it will accept the message and the final recipient server will bounce the mail back to you.

    I hope this helps.

    regards, Ruben

    Am 21.08.2012 18:52, schrieb Danilo Dionisi:

  • Hello,

    no problem at all, I think this is the tricky part.

    A smtp dialogue between your email client and a smtp server normally looks like this:

    user@box:~? netcat
    220 postfix ESMTP helo me.local
    250 mail from:
    250 2.1.0 Ok rcpt to:

    450 5.7.1
    : Mailbox Full

    The tricky part is writing or finding a console smtp client that gives you feedback about the 450 error that just happened. Right now I cannot give you a precise way to do that, but I have basic understanding of the technology, so I know that it is possible to do so 😉

    I’m looking around in the net, because I think I’ll soon have to handle your problem aswell in my company 😉
    If I can find solution, I’ll post it.

    regards, Ruben

    Am 21.08.2012 19:20, schrieb Danilo Dionisi:

  • It is not very difficult to write an ad-hoc script in a language like Python and call it instead of the regular sendmail command.

    Just look up something ‘Python smtp send tutorial’ and you should get a good starting point.

    Regards, Aldo

    Sent from my iPhone

  • Something like this ought to do it:

    (sleep 5; echo HELO foo; sleep 1; \
    echo mail from:; sleep 1; \
    echo rcpt to:; sleep 1; \
    echo data; echo test; echo .; sleep 1; echo quit) | \
    telnet 25 2>&1 | fgrep -q ‘450 5.7.1’ &&

    Of course, it’s probably better to wrap this into a Perl or equivalent script, but it should work on the shell too.


    — Raj

  • I would simply send the message with sendmail -v and then grep the output for the error message Il giorno 22/ago/2012 04:19, “Raj Mathur (राज माथुर)”
    ha scritto:

  • Yes, I’m root on the servers 😉
    But, the output for the error message, where is? Into /var/log/maillog?
    Sorry, but i’m newbie in this argument :p

    Il 22/08/12 07:02, Roberto Piola ha scritto:

  • How can I, with a bash script to take the standard output?
    When I take the standard output, I’ll do the grep to see if there is a code 450. Right?

    Il 22/08/12 11:56, Roberto Piola ha scritto:

  • Ok: this is the complete recipe.

    first, make a configuration file so that you are sure that sendmail tries to deliver directly to your server, and not to spool the file locally in order to send it later.

    cp /etc/mail/ /etc/mail/ vi +/^DS /etc/mail/ end modify the line that begins with DS (for smart relay host) into:

    save and then write a script like this:

    # this is the location of the temporary file for redirecting stdout-
    anything unique will go TEMPFILE=/dev/shm/checkeddelivery.$$
    /usr/lib/sendmail -v -g -C /etc/mail/ $*
    2>&1 >/dev/shm/checkeddelivery.$$
    if [ $? != 0 ]; then
    …. do domething: sendmail returned an immediate local error elif [ $( grep -c ^250\\.2\\.0\\.0 $TEMPFILE) == 0 ]; then
    …. something: sendmail did not get a “250 2.0.0 OK message” from the remote server
    …. just check that answers wth “250
    2.0.0 OK”, or adjust the script accordingly
    … here you can also check for some different errors and behave differently for over quota, fi
    #on the first runs, you may leave the file in order to inspect it rm $TEMPFILE

    and invoke the script as:
    myscript recipientaddress piping over standard input the complete mail you want to send (not only the .wav attachment)