Question(email to asterisk)

Hi,
Hope you all are fine.Can anyone tell me it is possible or not to send voice mail to asterisk through email client i.e, i opened my email client attach a voice message and send it to astrisk :frowning: . i have an idea but if some one reply me to show interest on this topic i share my idea with him. I m new to asterisk and want to do this thing in practical, so please reply this post so i share my idea with anyone who is interested in this topic.Or if anyone has knowledge of it please guide me.
.
Thanks in advance

It isn’t possbile to send an email directly to Asterisk, because it isn’t an smtp server.
You can have an smtp server that accepts the emails, that another program could check the email boxes and do something when a message is found, for example it could check if it is a voicemail-like email and convert it to an Asterisk voicemail or it could read the email, parse it, connect to the Asterisk manager and execute some commands.

Hope this helps you get things clearer.

Cheers.

Marco Bruni
www.marcobruni.net

Hi,
Hope you fine. Thanks Mr.Marco Bruni for your reply.Mr Marco now i tell you what is in my mind. Actually i think it is possible using the fax service(aster fax now called NoojeeFax).Because using this we can send email to asterisk in normal way as we send mail to others by configuring the sendmail. I know its only support text format file like pdf and doc and etcetra but wouldn’t you think that somehow we can use this service for this purpose. By defining the extension in the converter section of Noojeefax file. Can you please guide me if i want to do this what i supposed to do means any link to web site that contain information on this topic or any other guidance

Thank you very much .Again thanks for your reply

Sorry, don’t know the service you’re talking about and I’m not sure I understand…

Cheers.

Marco Bruni
www.marcobruni.net

Hello,
thanks for the reply

You have no idea how to do this, any guidance :frowning: actually i m talking about fax. You can send fax to asterisk through email client mention the fax number in the To field. You can also attach a text file and send it to asterisk but asterisk receive it as a fax. So is it possible to modify this approach for the voice mail also. what do you think. Actually i am working on it i just want to know whether i m moving in a right direction, is it possible by any means or i m wasting my time :confused:

Thanks in advance

Send an email to an smtp server and have a client that reads the emails and stores them (if in the right format) as Asterisk voicemails is doable.
Is this what you would like to do ?

Cheers.

Marco Bruni
www.marcobruni.net

Thanks Mr Marco,
Yes actually using mail client like @mail .What i want to do is i log in to my account like we log in to hotmail or yahoo, attach a voice mail, and send it to asterisk to whatever person’s extension and that person is able to listen it. Now the question is when i send email by what means i converted it to asterisk format what procedure i supposed to follow

Thank you very very much for your replies

Ok, now I’ve understood :smile:

So you need to write a client to read the emails sent to the email address that belongs to the Asterisk server (or you could have one email per extension), parse the emails and eventually create a new voicemail.
Some months ago I wrote a client that reads the emails, parses the contents and creates an object in a in the Sugar crm, so the only difference is you need to create an Asterisk voicemail instead of a Sugar crm object; I used php for the email client, with the help of the PEAR classes POP3 and Mime_Type and the classes rfc822_addresses and mime_parser from phpclasses.org; create a voicemail for Asterisk shoudn’t bee too difficult, just create the msgXXXX.wav file and the msgXXXX.txt files in the specific folder for the voicemail box, in the /var/spool/asterisk/voicemail directory, I suggest you to look to existing voicemail files for the details.

Cheers.

Marco Bruni
www.marcobruni.net

Hi Mr Marco,
Thank you very much for your replies it helps me a lot.Again thank you.But i have question that what is mean by

[color=green]write a client to read the emails sent to the email address that belongs to the Asterisk server (or you could have one email per extension)[/color]

Do you mean i should write an email client so it recognizes extension as an address of the person

Actually i want to know not in detail but a little bit explanation of the three points taht you told me to do. First you say write an email client ok thats fine some times ago i wrote an basic email client but in JAVA here i supposed to use PHP ok no problem i’ll manage but please could you expalin these point in breif

  1. to the email address that belongs to the Asterisk server (or you could have one email per extension)
    2.parse the emails
    3.create a new voicemail

Thank you very much for your assistance

  1. the address where you send the emails, could be 206@mypbx.domain.com;
  2. means read the email and extract the relevant informations;
  3. a voicemail is a message that an user can listen through the phone connected to the pbx.

If you know Java use it, you’re are not forced to use PHP.

Cheers.

Marco Bruni
www.marcobruni.net

:smile: Hello Mr Marco,
Thank you very much.Thank you very very much.One last thing :unamused: can you give me your contact information(email Id) so in future i’ll contact you or your website link if you have it :unamused:

             Thank you very much. Thank yooooooou veeeeeery much :smile:

Hello Mr Marco :smile:,
Hope you are at good health.It’s have been long time passed since we have talked.But i remind you the summary that i want to send voice email to asterisk using an email client and you guided me really well that how can i achieve this.After our discussion, i moved to some other project but now i am again working on it.
Actually i am stuck at a point and need your guidance, what i have done so far is that when i send a voice mail to my Asterisk server , right now i set domain nethyderabad.com to Asterisk server means if i send a voice mail to kashif@nethyderabad.com it goes to my Asterisk server, so when mail is sent through email client to nethyderabad.com it received by the send-mail there, there I then use procmail to filter my email and the condition is if you find voice-mail in the subject line then sent this mail to /var/spool/asterisk/voicemail/brights/220/INBOX i.e, the folder where Asterisk stores it’s voice messages.
Till now every thing is OK but the problem is when voice mail go to the INBOX folder and then i call to Asterisk it says you have no new voice email. I want to ask why it is happening, will i have supposed to convert it into Asterisk format, but my voicemail is also in wav format and my Asterisk also store messages in wav format. So please can you tell me what to do now.
One thing more that when i call to Asterisk and leave a voice message it manages file kike this

msg0000.txt
msg0000.wav

and then msg0001 and then msg0002 and so on

The mesg0000.txt contains things like

;
; Message Information file
;
[message]
origmailbox=202
context=internal-3
macrocontext=
exten=202
priority=3
callerchan=Zap/2-1
callerid=Unknown
origdate=Fri Oct 24 04:05:41 PM PKT 2008
origtime=1224846341
category=
duration=11

Now what we have done so far that when mail goes to asterisk through our procedure i.e., receive by sendmail and then filter by procmail and then go to Asterisk it store likes this

msg-5184-1.html
Voicemail277552.wav

and msg-5184-1.html contain things like

This Email has Voice maill attached :

this is a test voice mail to see whether it is working or not


Msg sent via NetKarachi - [netkarachi.com/](http://www.netkarachi.com/)

So is there any problem i mean to say that will i have suppose to convert it into Asterisk format means before sending it to INBOX run some sort of script that convert it so Asterisk recognize it.

Another thing may be because of this it is happening that when i call to Asterisk and leave a voice message, the message come into INBOX of a particular extension but after 3 to 5 seconds it’s deleted from the INBOx and go to the Asterisk database but my voice message(i.e., through procmail) is remain In the INBOX it’s not go to the database. So is this thing matter or it is a different issue.

Kindly please guide me because i am totally stuck now.

Thank you.

Hi, to create a voicemail you have to create two files in the INBOX folder:
msgNNNNtxt
msgNNNN.wav

Are you using a plain Asterisk install or some gui addon ? Please specify.

Cheers.

Marco Bruni
www.marcobruni.net

Hi :smile:,
Thank you. But how can i create these files.

msgNNNNtxt
msgNNNN.wav

Right now i have mentioned to you that how files are storing when i send voice mail to asterisk(i.e., through procmail procedure)

I am using plain asterisk i think because all the things i do is through commands. I am using Asterisk 1.4.18.1.

One thing more can you please tell me if i don’t want to store my voice messages in a database and want to remain it in the INBOX folder how can i do it.

Thank you

Extract the wav file attached to the email and save it as msgNNNN.wav, then create the msgNNNN.txt, a normal text file, using the right format, check the right format in a msgNNNN.txt created through the stadandard Asterisk voicemail, sorry but can’t help you with procmail as I don’t use .it.

This is what is not clear, I checked the standard voicemail.conf, if you are using plain Asterisk messages should remain in the voicemail directory.

Cheers.

Marco Bruni
marcobruni.net

Hi,
Thanks. Ok i understood. But tell me one thing when I’ll extract the voice mail and create a normal text file (msgNNNN.txt), what text does this file have contain. When i record a message to Astersik for extension 206, it’s text file look like this

;
; Message Information file
;
[message]
origmailbox=206
context=office
macrocontext=
exten=206
priority=3
callerchan=SIP/208-09fb58c0
callerid=“Bashir” <208>
origdate=Fri Oct 31 08:46:27 PM PKT 2008
origtime=1225467987
category=
duration=2

So did you mean if i want to send my email to 220 extension i will have to create a text file with all above parameters (origmailbox, context, macrocontext, exten, priority and so on with values corresponding to ext 220)

What do you mean by plain Asterisk? If i use make menuselect to disable ODBC is this right approach to do it? means will this stop storing messages in database or not or it causes some other problems to rise.

Thank you

Yes.

With “plain” Asterisk I mean an Asterisk compiled from sources without any sort of gui, don’t think you need to disable odbc, will check better about voicemails database storage and wiil let you know.

Cheers.

Marco Bruni
www.marcobruni.net

Hi,
Thank you :smile:. OK now i work on this part that is extracting and creating file.Thank you very much :smile:

Thank you :wink:

Ok, didn’t remember, in 1.4, as you told me, there is a “make menuselect” option to store the voicemails in an odbc database, so deselect ODBC_STORAGE in “Voicemail Build Options” and your voicemail messages should remain in the directory without any side effect.

Cheers.

Marco Bruni
marcobruni.net

HI Mr Marco,
Thanks for your help. But after deselecting the ODBC_STORAGE in “Voicemail Build Options” and then after running make command it gives me error like this

[LD] abstract_jb.o acl.o aescrypt.o aeskey.o aestab.o alaw.o app.o ast_expr2.o ast_expr2f.o asterisk.o astmm.o astobj2.o audiohook.o autoservice.o callerid.o cdr.o channel.o chanvars.o cli.o config.o cryptostub.o db.o devicestate.o dial.o dns.o dnsmgr.o dsp.o enum.o file.o fixedjitterbuf.o frame.o fskmodem.o global_datastores.o http.o image.o indications.o io.o jitterbuf.o loader.o logger.o manager.o md5.o netsock.o pbx.o plc.o privacy.o rtp.o say.o sched.o sha1.o slinfactory.o srv.o stdtime/localtime.o strcompat.o tdd.o term.o threadstorage.o translate.o udptl.o ulaw.o utils.o editline/libedit.a db1-ast/libdb1.a -> asterisk
/usr/bin/ld: cannot find -lcap
collect2: ld returned 1 exit status
make[1]: *** [asterisk] Error 1
make: *** [main] Error 2

I have already installed lcap. Can you please tell me why this error is coming and what it’s mean
First i thought may be my asterisk is running that’s why it is coming but after stoping the asterisk the situation remain same and also when i run my asterisk it gives me warning that

[Nov 13 16:33:08] WARNING[16997]: chan_sip.c:1786 __sip_xmit: sip_xmit of 0x9d70d08 (len 580) to 116.71.34.35:34620 returned -2: Bad file descriptor
[Nov 13 16:33:08] WARNING[16997]: chan_sip.c:1786 __sip_xmit: sip_xmit of 0x9d71188 (len 582) to 116.71.38.8:59126 returned -2: Bad file descriptor
[Nov 13 16:33:08] WARNING[16997]: chan_sip.c:1786 __sip_xmit: sip_xmit of 0x9df8500 (len 582) to 116.71.51.138:51009 returned -2: Bad file descriptor

and these warnings are continuously coming . So please can you tell me why these warnings and the above mentioned error are coming

Thank you