Check For The Voicemail

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? :(

Danilo

17 Responses to “Check For The Voicemail”

  1. Danny Nicholas said:

    Aug 21, 12 at 11:47 am

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

    —–Original Message—

  2. Ruben Rögels said:

    Aug 21, 12 at 11:53 am

    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:

  3. Danilo Dionisi said:

    Aug 21, 12 at 11:53 am

    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:

  4. Danilo Dionisi said:

    Aug 21, 12 at 11:55 am

    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

  5. Carlos Rojas said:

    Aug 21, 12 at 11:55 am

    Hello

    Check voicemail.conf

    maxmsg = 100

    And change it.

  6. Danilo Dionisi said:

    Aug 21, 12 at 12:03 pm

    I’ll explain. I have an email account, danilo.dionisi @ outlook.it, 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:

  7. Danilo Dionisi said:

    Aug 21, 12 at 12:29 pm

    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

  8. Ruben Rögels said:

    Aug 21, 12 at 12:29 pm

    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:

  9. Ruben Rögels said:

    Aug 21, 12 at 12:32 pm

    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 mx1.example.com
    220 postfix ESMTP mx1.example.com helo me.local
    250 mx1.example.com 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:

  10. Aldo Bergamini said:

    Aug 21, 12 at 12:55 pm

    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

  11. Raj Mathur said:

    Aug 21, 12 at 9:17 pm

    Something like this ought to do it:

    (sleep 5; echo HELO foo; sleep 1; \
    echo mail from: foo@example.com; sleep 1; \
    echo rcpt to: userid.that@youwant.to.check; sleep 1; \
    echo data; echo test; echo .; sleep 1; echo quit) | \
    telnet mail.ho.st 25 2>&1 | fgrep -q ‘450 5.7.1′ && notify-user.sh

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

    Regards,

    – Raj

  12. Roberto Piola said:

    Aug 22, 12 at 12:06 am

    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:

  13. Raj Mathur said:

    Aug 22, 12 at 12:34 am

    Er, that works too :) Much better solution (as long as you are root).

    Regards,

    – Raj

  14. Danilo Dionisi said:

    Aug 22, 12 at 4:54 am

    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:

  15. Roberto Piola said:

    Aug 22, 12 at 4:56 am

    no. when you issue sendmail -v …., the output is sent on the standard output

  16. Danilo Dionisi said:

    Aug 22, 12 at 5:11 am

    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:

  17. Roberto Piola said:

    Aug 22, 12 at 5:35 am

    Ok: this is the complete recipe.

    first, make a sendmail.cf 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/sendmail.cf /etc/mail/direct-delivery-sendmail.cf vi +/^DS /etc/mail/direct-delivery-sendmail.cf end modify the line that begins with DS (for smart relay host) into:
    DSyour.exchange.server.name

    save and then write a script like this:

    #!/bin/bash
    # 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/direct-delivery-sendmail.cf $*
    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 your.exchange.server.name 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)