Send email alerts when voicemailbox is full

hi Team,

I want to setup alert emails on voicemailbox full of the user.

so, when a user’s voicemailbox is full we want to send an email alerting him about the storage that his mailbox is full.

This would send a message when there are 99 messages

for i in $(ls /var/spool/asterisk/voicemail/default/*/INBOX/msg*99.txt |cut -d '/' -f 7);
do echo "echo 'mailbox is full'| mail -s 'a vmail warning' $(grep $i= /etc/asterisk/voicemail.conf|cut -d ',' -f 3)";
done

use it in a cronjob perhaps

2 Likes

and I can set to any message limit
Can I send this to any specific user as well

of course, just edit the script for mail destination , comedian mail has a setting maxmsg= which is 100 by default,

I have tested this script with the following ammendments

for i in $(ls /var/spool/asterisk/voicemail/default/*/INBOX/msg*9.txt |cut -d '/' -f 7); do echo "echo 'mailbox is full'| mail -s 'This is a Voicemail Box warning' $(grep $i= /etc/asterisk/voicemail.conf|cut -d ',' -f 3)"; done

echo 'mailbox is full'| mail -s 'This is a Voicemail Box warning' 
echo 'mailbox is full'| mail -s 'This is a Voicemail Box warning' 
echo 'mailbox is full'| mail -s 'This is a Voicemail Box warning' 
echo 'mailbox is full'| mail -s 'This is a Voicemail Box warning' 
echo 'mailbox is full'| mail -s 'This is a Voicemail Box warning' 
echo 'mailbox is full'| mail -s 'This is a Voicemail Box warning' 
echo 'mailbox is full'| mail -s 'This is a Voicemail Box warning' 
echo 'mailbox is full'| mail -s 'This is a Voicemail Box warning' 
echo 'mailbox is full'| mail -s 'This is a Voicemail Box warning' 
echo 'mailbox is full'| mail -s 'This is a Voicemail Box warning'

but no email sent to any user. logs are also empty

That you can pipe through shell or take out the outside echo " …" but you need to get an email address, the $i you could echo or add in to the mail subject. Here an stating point

for i in $(ls /var/spool/asterisk/voicemail/default/*/INBOX/msg*97.txt |cut -d '/' -f 7); do 
echo $i;
grep "$i=" /etc/asterisk/voicemail.conf; 
done

I want to run it company wide for every voicemailbox

My script should do that, presuming that all your extensions’ are in the ‘default’ voicemail.context, if not adjust the script, replace ‘default’ with ‘*’ while scanning the voicemail directories.

The intent is to scan all voicemails that are in any INBOX, thus identifying any extension that has a voicemail numbered at or above the count you specify thusly finding extensions that are approaching being ‘full’ (maxmsg being identified by you) , having found any, interrogate voicemail.conf for the relevant email of the culprit extension(s) and so inform them.

it shows the extensions successfully but how can I create a proper email alert for every user it pulled out and it will automatically send email notification alert of mailbox full


104
129
131
139
152
165
174
182
188
196
312
325
360
366
417
521

These Extensions are full

As I showed, pedantically lets start with baby steps , you say for example that the mail box for 188 is full so

ls -lsrt /var/spool/asterisk/voicemail/default/*/INBOX/*.txt

returns what when you look at the 188 bits ?

so by individual isolation we can

grep 188 /etc/asterisk/voicemail.conf

which returns ‘what?’

Chances are you now have knowledge of the number of emails by extension, and if the user has been set up with email, then , what do you know! , it’s there in voicemail.conf.

All my script does is plug all that together. there is no magic here, just shell scripting.

That would be if you’re using the default settings on a mailbox. The amount of messages that are limited to a mailbox is based on the mailbox config. For example, I have users that have 150/200 messages allowed in their mailboxes. The max is 9999 and 0 means greetings will only be played.

I also use the ‘externalnotify’ option which runs a script each time a voicemail is left/delivered/checked. I can check for a new voicemail or an event and process what I need from there. This includes transcribing the new voicemail, converting it to an mp3 format and emailing it with the mp3 attachment and transcript in the body. Being able to check how many messages are in the mailbox could be done here as well.

Also, if you’re going to do this at the system level I’d go with systemd timers over cronjob because you have more flexibility, options and better handling of the process.

Do you notice my

of course, just edit the script for mail destination , comedian mail has a setting maxmsg= which is 100 by default,

Better than a systemd timer service yet would be a systemd path service, which is what I use, It can nicely expand on externnotify, but I suspect both are as yet out of reach if the OP.

still not able to send email alert for the mailboxes which are full. :frowning:

Recommend that at this point you go work out the issues using standard troubleshooting methods; that is, write your script, add debugging to it if it doesn’t work right away, iterate over it until it works. You have been given some suggestions here in the thread and it is starting to look like a “do this work for me for free” kind of thread, which folks here tend not to appreciate.

2 Likes

I really like this. Thanks.

1 Like

Let us know when you get some traction.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.