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
Danny Nicholas said:
Aug 21, 12 at 11:47 amAssuming that you are using the standard 100 message limit, just check for INBOX/MSG0100.txt and send the message.
—–Original Message—
Ruben Rögels said:
Aug 21, 12 at 11:53 amjust 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:
Danilo Dionisi said:
Aug 21, 12 at 11:53 amI’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:
Danilo Dionisi said:
Aug 21, 12 at 11:55 amThe 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
Carlos Rojas said:
Aug 21, 12 at 11:55 amHello
Check voicemail.conf
maxmsg = 100
And change it.
Danilo Dionisi said:
Aug 21, 12 at 12:03 pmI’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:
Danilo Dionisi said:
Aug 21, 12 at 12:29 pmI’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
Ruben Rögels said:
Aug 21, 12 at 12:29 pmOkay, 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:
Ruben Rögels said:
Aug 21, 12 at 12:32 pmHello,
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: Mailbox Full
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
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:
Aldo Bergamini said:
Aug 21, 12 at 12:55 pmIt 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
–
Raj Mathur said:
Aug 21, 12 at 9:17 pmSomething 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
Roberto Piola said:
Aug 22, 12 at 12:06 amI 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:
Raj Mathur said:
Aug 22, 12 at 12:34 amEr, that works too
Much better solution (as long as you are root).
Regards,
– Raj
Danilo Dionisi said:
Aug 22, 12 at 4:54 amYes, 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:
Roberto Piola said:
Aug 22, 12 at 4:56 amno. when you issue sendmail -v …., the output is sent on the standard output
Danilo Dionisi said:
Aug 22, 12 at 5:11 amHow 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:
Roberto Piola said:
Aug 22, 12 at 5:35 amOk: 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)