IMAP Storage with Asterisk

Hello,

I’ve finally managed to make an IMAP server working with Asterisk. I’m using Asterisk 1.4 with the UW imap 2006e but i have a few problems.

1st. When someone has a new message in his voicemail, he gets 2 email in his IMAP account, one with the voicemail attached in .wav & .gsm, and one with the voicemail attached in .wav . What can I do so that it only sends 1 message (the first one) ?

2nd. If someone logs into his account using a phone, and changes the folder of a message (by example, changing a message from INBOX to Work), the message is copied and not moved, how can I change that?

I don’t know if those are “bugs” or if it has been done on purpose, because I’ve looked a few in the “app_voicemail.c” and it seems like it has been done on purpose, but I’m not a pro :wink:

If anyone can help me :wink:

Thank You.

Hi,

Can you put some details about your installation in there, it could help:
forums.digium.com/viewtopic.php?t=13197

Regarding issue #1, all I saw on this: bugs.digium.com/view.php?id=8873
Looks like it’s been reported as a bug, but no patches or anything yet.

Funny thing however… did you tell asterisk to attach a voicemail message and send it to the person’s email which is the same as the IMAP account?

Also have you tried specifying only one format? Like only gsm, does it send two messages then?

I’m not sure as I haven’t been able to get IMAP working yet.

To answer you, yes I’ve tried a lot of things.

Specifying only 1 format: if I specify only gsm, it doesn’t create the wav, but it still sends 2 messages, both have the .gsm.
I’ve looked into app_voicemail.c, and it seems like it’s doing one mail with the format you’ve configured, and one mail with the first format that is written (so if you’ve put format=wav|gsm, first mail will be wav + gsm, second will be only wav). The gsm is always needed for asterisk, if you want your users to hear the voicemail using a phone, so you’ve to let it there.

When i create the mailbox,by example:
555 => 0000,Example Mailbox,toto@localhost,imapuser=toto|imappassword=toto
Here, it’ll use this email for the 2nd message that is sent (the one with the 1st format only). If i add attach=no, it’ll not attach the file, but it’ll still send the message. If I don’t write an email, it still sends it to the email o.O (but I have to try that after a reboot, maybe it kept the email somewhere so I have to reboot?).

Then I looked into the app_voicemail.c
I’ve found out where it sent the mail with the first formay only, search for “Sent mail to” in the file and remplace lines by that:

	} else {
		/*
		make_email_file(p, srcemail, vmu, msgnum, context, mailbox, cidnum, cidname, attach, format, duration, attach_user_voicemail, chan, category, 0);
		*/
		fclose(p);
		/*
		snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp);
		*/
		ast_safe_system(tmp2);
		ast_log(LOG_DEBUG, "Sent mail to %s with command '%s'\n", vmu->email, mailcmd);
	 }

Now for my 2nd problem, I haven’t found it yet in the code, as it’s more compexe when it copies the file, but I’ll find it!! :stuck_out_tongue:
If someone changes the file of folder using a phone, and then he tries to login using a mail client too fast, it’ll lock the account for a few minutes, because Asterisk was still connected to it. Well that’s how I understand what it did :stuck_out_tongue:
I think you can change the lock timer somewhere in the uw-imap source, but I haven’t found it, only found it in the ipop source, which is useless for me :wink:

Now I realise this will be somewhat disconcerting to you, but I finally got it to work and, well, I’m not experiencing bug #1. I only seem to get one message. I’ve tried with all three formats, it sent one message with only the first two formats. I’ve put only wav49, and it sends only one message…?

Peculiar, I’ll run some more tests!

Thanks for the hint about the “notls” flag!

I’ve discovered that if you want the novalidate-cert, you have to compile imap-2006e with ssl support, and then it works fine.

As a matter of fact it’s LESS complicated with SSL/TLS than without. Go figure.