= Configurations pour joindre les messages reçus dans la boîte vocale aux courriels de notification = == Modifier le fichier `/etc/asterisk/voicemail.conf` == * Changer le format des messages vocaux * Activer l'option pour les joindre aux courriels * Changer le corps du message envoyé * Changer la commande d'envoi des courriels. Le script utilisé va convertir les messages vocaux du format wav au format mp3. {{{#!highlight diff @@ -8,7 +8,7 @@ ; Formats for writing Voicemail. Note that when using IMAP storage for ; voicemail, only the first format specified will be used. ;format=g723sf|wav49|wav -format = gsm +format = wav|gsm ; @@ -27,7 +27,7 @@ format = gsm serveremail = assistance-informatique@auf.org ;serveremail=asterisk@linux-support.net ; Should the email contain the voicemail as an attachment -attach = no +attach = yes @@ -98,7 +98,7 @@ emailsubject = [BoiteVocale ${VM_MAILBOX}] Nouveau message ${VM_MSGNUM} dans la ; just the CIDNAME, if it is not null, otherwise just the CIDNUM, or "an unknown ; caller", if they are both null. ;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\n ... +${VM_MSGNUM}\n\nCliquez sur la pièce jointe pour écouter le message.\n\nVous pouvez aussi consulter votre messagerie vocale en composant *66; @@ -118,6 +118,7 @@ emaildateformat = le %d %B %Y à %H:%M:%S ; You can override the default program to send e-mail if you wish, too ; ;mailcmd=/usr/sbin/sendmail -t +mailcmd=/usr/local/sbin/sendmailmp3 }}} == Installer les paquets requis == * Paquets requis * dos2unix * lame * sox * Où trouver les paquets pour nos vieux serveurs Lenny * [[http://archive.debian.org/debian/pool/main/d/dos2unix/dos2unix_6.0-1_i386.deb|dos2unix]] * [[http://old-releases.ubuntu.com/ubuntu/pool/multiverse/l/lame/lame_3.98.2+debian-0ubuntu2_i386.deb|lame : version de chez Ubuntu]] * sox : avec la source http://archive.debian.org lenny/main (`aptitude install sox`) == Le script de conversion wav vers mp3 == {{{#!highlight shell #!/bin/sh # Asterisk voicemail attachment conversion script # Revision history : # 22/11/2010 - V1.0 - Creation by N. Bernaerts # 07/02/2012 - V1.1 - Add handling of mails without attachment (thanks to Paul Thompson) # 01/05/2012 - V1.2 - Use mktemp, pushd & popd # 08/05/2012 - V1.3 - Change mp3 compression to CBR to solve some smartphone compatibility (thanks to Luca Mancino) # 01/08/2012 - V1.4 - Add PATH definition to avoid any problem (thanks to Christopher Wolff) # 16/07/2015 - V1.5 - Handle natively GSM WAV (thanks to Michael Munger) # set PATH PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" # save the current directory pushd . # create a temporary directory and cd to it TMPDIR=`mktemp -d` cd $TMPDIR # dump the stream to a temporary file cat >> stream.org # get the boundary BOUNDARY=`awk -F'"' '/boundary=/ {print $2}' stream.org` # cut the file into parts # stream.part - header before the boundary # stream.part1 - header after the bounday # stream.part2 - body of the message # stream.part3 - attachment in base64 (WAV file) # stream.part4 - footer of the message awk "/$BOUNDARY/{i++}{print > \"stream.part\"i}" stream.org # if mail is having no audio attachment (plain text) if grep -q 'plain' stream.part1 then # prepare to send the original stream cat stream.org > stream.new # else, if mail is having audio attachment else # cut the attachment into parts # stream.part3.head - header of attachment # stream.part3.wav.base64 - wav file of attachment (encoded base64) sed '7,$d' stream.part3 > stream.part3.wav.head sed '1,6d' stream.part3 > stream.part3.wav.base64 # convert the base64 file to a wav file dos2unix -o stream.part3.wav.base64 base64 -di stream.part3.wav.base64 > stream.part3.wav # convert wave file (GSM encoded or not) to PCM wav file sox stream.part3.wav stream.part3-pcm.wav # convert PCM wav file to mp3 file # -b 24 is using CBR, giving better compatibility on smartphones (you can use -b 32 to increase quality) # -V 2 is using VBR, a good compromise between quality and size for voice audio files lame -m m -b 32 stream.part3-pcm.wav stream.part3.mp3 # convert back mp3 to base64 file base64 stream.part3.mp3 > stream.part3.mp3.base64 # generate the new mp3 attachment header # change Type: audio/x-wav or audio/x-WAV to Type: audio/mpeg # change name="msg----.wav" or name="msg----.WAV" to name="msg----.mp3" sed 's/x-[wW][aA][vV]/mpeg/g' stream.part3.wav.head | sed 's/.[wW][aA][vV]/.mp3/g' > stream.part3.mp3.head # generate first part of mail body, converting it to LF only mv stream.part stream.new cat stream.part1 >> stream.new cat stream.part2 >> stream.new cat stream.part3.mp3.head >> stream.new dos2unix -o stream.new # append base64 mp3 to mail body, keeping CRLF unix2dos -o stream.part3.mp3.base64 cat stream.part3.mp3.base64 >> stream.new # append end of mail body, converting it to LF only echo "" >> stream.tmp echo "" >> stream.tmp cat stream.part4 >> stream.tmp dos2unix -o stream.tmp cat stream.tmp >> stream.new fi # send the mail thru sendmail cat stream.new | sendmail -t # go back to original directory popd # remove all temporary files and temporary directory #rm -Rf $TMPDIR }}} ----