Configurations pour joindre les messages reçus dans la boîte vocale aux courriels de notification

Modifier le fichier `/etc/asterisk/voicemail.conf`

   1 @@ -8,7 +8,7 @@
   2  ; Formats for writing Voicemail.  Note that when using IMAP storage for
   3  ; voicemail, only the first format specified will be used.
   4  ;format=g723sf|wav49|wav
   5 -format = gsm
   6 +format = wav|gsm
   7  ;
   8 
   9 @@ -27,7 +27,7 @@ format = gsm
  10  serveremail = assistance-informatique@auf.org
  11  ;serveremail=asterisk@linux-support.net
  12  ; Should the email contain the voicemail as an attachment
  13 -attach = no
  14 +attach = yes
  15 
  16 @@ -98,7 +98,7 @@ emailsubject = [BoiteVocale ${VM_MAILBOX}] Nouveau message ${VM_MSGNUM} dans la
  17  ; just the CIDNAME, if it is not null, otherwise just the CIDNUM, or "an unknown
  18  ; caller", if they are both null.
  19  ;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
  20 ...
  21 +${VM_MSGNUM}\n\nCliquez sur la pièce jointe pour écouter le message.\n\nVous pouvez aussi consulter votre messagerie vocale en composant *66;
  22 
  23 
  24 @@ -118,6 +118,7 @@ emaildateformat = le %d %B %Y à %H:%M:%S
  25  ; You can override the default program to send e-mail if you wish, too
  26  ;
  27  ;mailcmd=/usr/sbin/sendmail -t
  28 +mailcmd=/usr/local/sbin/sendmailmp3
  29 

Installer les paquets requis

Le script de conversion wav vers mp3

   1 #!/bin/sh
   2 # Asterisk voicemail attachment conversion script
   3 # Revision history :
   4 # 22/11/2010 - V1.0 - Creation by N. Bernaerts
   5 # 07/02/2012 - V1.1 - Add handling of mails without attachment (thanks to Paul Thompson)
   6 # 01/05/2012 - V1.2 - Use mktemp, pushd & popd
   7 # 08/05/2012 - V1.3 - Change mp3 compression to CBR to solve some smartphone compatibility (thanks to Luca Mancino)
   8 # 01/08/2012 - V1.4 - Add PATH definition to avoid any problem (thanks to Christopher Wolff)
   9 # 16/07/2015 - V1.5 - Handle natively GSM WAV (thanks to Michael Munger)
  10 
  11 # set PATH
  12 PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
  13 
  14 # save the current directory
  15 pushd .
  16  
  17 # create a temporary directory and cd to it
  18 TMPDIR=`mktemp -d`
  19 cd $TMPDIR
  20  
  21 # dump the stream to a temporary file
  22 cat >> stream.org
  23  
  24 # get the boundary
  25 BOUNDARY=`awk -F'"' '/boundary=/ {print $2}' stream.org`
  26  
  27 # cut the file into parts
  28 # stream.part - header before the boundary
  29 # stream.part1 - header after the bounday
  30 # stream.part2 - body of the message
  31 # stream.part3 - attachment in base64 (WAV file)
  32 # stream.part4 - footer of the message
  33 awk "/$BOUNDARY/{i++}{print > \"stream.part\"i}" stream.org
  34  
  35 # if mail is having no audio attachment (plain text)
  36 if grep -q 'plain' stream.part1
  37 then
  38  
  39   # prepare to send the original stream
  40   cat stream.org > stream.new
  41  
  42 # else, if mail is having audio attachment
  43 else
  44   # cut the attachment into parts
  45   # stream.part3.head - header of attachment
  46   # stream.part3.wav.base64 - wav file of attachment (encoded base64)
  47   sed '7,$d' stream.part3 > stream.part3.wav.head
  48   sed '1,6d' stream.part3 > stream.part3.wav.base64
  49  
  50   # convert the base64 file to a wav file
  51   dos2unix -o stream.part3.wav.base64
  52   base64 -di stream.part3.wav.base64 > stream.part3.wav
  53 
  54   # convert wave file (GSM encoded or not) to PCM wav file
  55   sox stream.part3.wav stream.part3-pcm.wav
  56  
  57   # convert PCM wav file to mp3 file
  58   # -b 24 is using CBR, giving better compatibility on smartphones (you can use -b 32 to increase quality)
  59   # -V 2 is using VBR, a good compromise between quality and size for voice audio files
  60   lame -m m -b 32 stream.part3-pcm.wav stream.part3.mp3
  61  
  62   # convert back mp3 to base64 file
  63   base64 stream.part3.mp3 > stream.part3.mp3.base64
  64  
  65   # generate the new mp3 attachment header
  66   # change Type: audio/x-wav or audio/x-WAV to Type: audio/mpeg
  67   # change name="msg----.wav" or name="msg----.WAV" to name="msg----.mp3"
  68   sed 's/x-[wW][aA][vV]/mpeg/g' stream.part3.wav.head | sed 's/.[wW][aA][vV]/.mp3/g' > stream.part3.mp3.head
  69  
  70   # generate first part of mail body, converting it to LF only
  71   mv stream.part stream.new
  72   cat stream.part1 >> stream.new
  73   cat stream.part2 >> stream.new
  74   cat stream.part3.mp3.head >> stream.new
  75   dos2unix -o stream.new
  76  
  77   # append base64 mp3 to mail body, keeping CRLF
  78   unix2dos -o stream.part3.mp3.base64
  79   cat stream.part3.mp3.base64 >> stream.new
  80  
  81   # append end of mail body, converting it to LF only
  82   echo "" >> stream.tmp
  83   echo "" >> stream.tmp
  84   cat stream.part4 >> stream.tmp
  85   dos2unix -o stream.tmp
  86   cat stream.tmp >> stream.new
  87  
  88 fi
  89  
  90 # send the mail thru sendmail
  91 cat stream.new | sendmail -t
  92  
  93 # go back to original directory
  94 popd
  95  
  96 # remove all temporary files and temporary directory
  97 #rm -Rf $TMPDIR
  98 


Asterisk/JoindreMessageVocalAuxCourriels (dernière édition le 2019-02-26 14:30:27 par MoussaNombre)