Posts tagged: mailcall

Get Your Email By Telephone: Introducing MailCall for Asterisk 1.4

Well, it's Happy Birthday to Us week at Nerd Vittles. This week marks our Third Anniversary, and today we're publishing our 200th column. Wow! Eighteen months ago, we first introduced MailCall for Asterisk®. It joined dozens of other telephony applications named MailCall with one important difference. Ours is FREE! What do it do? Well, it reads your email messages to you over the telephone. All you have to do is dial up your Asterisk server from any touchtone telephone. Can it handle multiple email accounts? Absolutely. Do the email accounts have to be on the Asterisk server? Nope. Does it work with POP3 and IMAP mail accounts? Yep. Which email messages can it speak? We've tried it successfully with messages from Yahoo, and HotMail, and Google Mail, and Comcast Mail, and RoadRunner, and Outlook Express, and Notes Mail, and Entourage. And it works with plain text messages as well as those with attachments although it doesn't deal with the attachments. No, it can't tell you what kind of picture is lurking in your inbox. Maybe someday. If you happen to be running a current version of PBX in a Flash, then deploying MailCall for Asterisk 1.4 will take you about 15 minutes to set up. For other versions of Asterisk, you'll need to install Apache, PHP, the php-imap library, FreePBX, and the Flite voice processing system. You can scratch around on Nerd Vittles for most of the tutorials. But the easiest way to get this up and running quickly is to install PBX in a Flash and get the latest updates using our tutorial. You can't beat FREE!

Overview. The way MailCall for Asterisk 1.4 works is pretty straight-forward. You add a code snippet to the extensions_custom.conf config file for each mail account you wish to activate. This is where you tell Asterisk which extension to dial to play back your messages. Then you drop a PHP script into the AGI script directory. Finally you create a configuration file for each email account you wish to set up. The config file tells MailCall the name of your provider, your username, your email password, and the 4-digit password you wish to use to access your messages by phone. Once you reload Asterisk 1.4, you'll be off to the races.

Dial the extension and enter your password for this account. MailCall for Asterisk 1.4 will connect to your mail server and tell you how many messages are sitting in your mailbox. Press 1 to play the most recent message. After it plays, you can press 5 to replay the message, press 6 to play the next most recent message in your mailbox, press 4 to play the previous message (if any), press 0 to retrieve a specific message, press * for a list of options, or press # to exit. These are the same buttons you press for these functions in the Asterisk voicemail system, formerly Comedian Mail. We tried not to reinvent the wheel although the options aren't especially intuitive. We've also built a quick-and-dirty web interface to let you test access to your email accounts. The idea is to get PHP working with your email account and then copy the config file settings to your MailCall config file. You'll find it easier to debug connection problems using a web browser rather than using a telephone.

Getting Started. Let's take first things first. Before proceeding with the installation, make sure you are running an Asterisk 1.4 system with all the necessary components outlined above. If you're still running a system with Asterisk 1.2, read our old tutorial instead. Unless you're running PBX in a Flash, you'll need to install and configure Apache, PHP, the php-imap library with all dependencies, SendMail, and the Flite speech synthesis engine. Once you get all of the pieces properly configured and talking to each other, you'll be in the same place as those that used our tutorial to set up PBX in a Flash in about 30 minutes. We've also got a 15-second MailCall installation script for PBX in a Flash users. If you use it, you then can skip the remaining installation steps below and just do the configuring.

Running the PBX in a Flash Install Script. Only use this script if you're running a PBX in a Flash system. It is design-specific and will break things if it is run on other Asterisk 1.4 systems. The remainder of this tutorial will walk you through manually installing the software on other implementations of Asterisk 1.4. On PBX in a Flash systems, log in as root and execute the following commands:

cd /root
wget http://bestof.nerdvittles.com/applications/mailcall/mailcall.pbx
chmod +x mailcall.pbx
./mailcall.pbx
amportal restart

Once you've run the script, you can skip through the installation steps below, but you still need to configure both the web component and the Asterisk component so that MailCall knows how to retrieve your email. It'll just take you a couple of minutes.

Missing Pieces. Unless you used our install script, two important pieces are missing on most out-of-the-box systems including the base install of PBX in a Flash. The first is php-imap support for Apache. And the second is a simple tool to send fax and email messages from within your server. You can test whether your system includes php-imap support (which allows you to access and read from pop3 and imap mail servers) by creating a simple one-line PHP application called test.php in /var/www/html and running it from your web browser. If you care about the security of your web server, do NOT leave this application on your server after the test!!

<?php echo phpinfo() ; ?>

From a web browser, go to http://192.168.0.1/test.php using the correct IP address of your server. Immediately after the Apache HTTP Headers Information section, there will be an alphabetical listing of each of the modules supported on your Apache server. Look through the list and be sure you have an entry that looks something like the following:

imap
IMAP c-Client Version   2004
SSL Support   enabled
Kerberos Support   enabled

To install php-imap support, run the following commands after logging into your server as root:

yum install php-imap
apachectl restart

For the missing mime-construct component, execute the following commands:

cd /usr/local/bin
wget http://nerdvittles.com/trixbox123/mime-construct
chmod +x mime-construct

Installing the Web Interface. To install the web interface that you'll use for testing PHP access to your email account, log into your server as root and issue the following commands:

cd /var/www/html
mkdir readmail
cd readmail
wget http://nerdvittles.com/mailcall/webstuff.zip
unzip webstuff.zip
rm -f webstuff.zip
cp config.php config.bak.php

Testing Your First Mail Account. While you're still in the readmail directory, let's set up your first email account to make sure everything is working. If you've configured an email account previously in Outlook Express or some other mail reader, take a look at your configuration there and write down the settings. We'll need to know the fully-qualified domain name for your mail server, the type of mail account you have (POP3 or IMAP), the port used to access your mail and whether it's encrypted, and your username and email password. Here's what the settings for Gmail accounts should look like:

$MAILSERVER="pop.gmail.com:995/pop3/ssl";
$USER = "yourname@gmail.com" ;
$PW = "yourpassword" ;

If your email domain is hosted by a hosting provider such as our favorite, BlueHost, then here's the way the settings should look for your POP3 account:

$MAILSERVER="yourdomain.org:110/pop3";
$USER = "username+yourdomain.org" ;
$PW = "password" ;

For an IMAP mail account, the settings should look something like the following:

$MAILSERVER="yourdomain.org:143/imap";
$USER = "username+yourdomain.org" ;
$PW = "password" ;

Some ISPs require both your username and the domain as your login name. Others only want your account name. Whatever is working with your current mail client to successfully retrieve your email is what you should use here. Note that you must add both :portnumber and either /pop3 or /imap onto the end of your mail domain entry. We've made a duplicate of the config.php file for you just in case you mess up. Once you have your settings in hand, edit the config.php file in the readmail folder: nano -w config.php. Make the necessary entries and be sure you preserve the quotes around the entries as well as the semicolon at the end of each line. When you're finished, save your changes: Ctrl-X, Y, then Enter. Now open a web browser and go to http://IPaddressOfYourServer/readmail/. You should get a list of messages in your Inbox. When you click on a message, it should display in the browser. Get this working first before proceeding. Don't worry if some of the messages don't look quite right. We made some improvements in the MailCall application after the web interface was completed.

Newbie Alert: We ALWAYS love to hear from the Nerd Vittles Fan Club but ... If you have problems getting this to work, DON'T SEND ME EMAILS ASKING FOR HELP. Post your setup and your problem on the PBX in a Flash Help Forum and someone (maybe even me) will respond. This assists not only you but also anyone else with a similar problem. The blog format used for Nerd Vittles just isn't suitable for tech support ... and neither am I usually.

Modifying Your Dialplan. As indicated above, we need to add some code to the extensions_custom.conf file for each mail account you want to access. The basic code looks like this:

exten => 555,1,Answer
exten => 555,2,Wait(1)
exten => 555,3,Set(TIMEOUT(digit)=7)
exten => 555,4,Set(TIMEOUT(response)=10)
exten => 555,5,Flite("At the beep enter your e-mail password.")
exten => 555,6,Read(PWCODE,beep,4)
exten => 555,7,Flite("Please hold a moment.")
exten => 555,8,AGI(nv-mailcall.php|${PWCODE})
exten => 555,9,Flite("Thank you for calling. Good bye.")
exten => 555,10,Hangup

The only change you need to make is in the extension number (555) on each line. This tells Asterisk what number you'll be calling to retrieve your messages. If you want to access more than one email account, then you simply duplicate the above code with different extension numbers. Just be sure that all 10 lines of each code snippet have the same extension number. If you don't like four-digit phone passwords, you can change the length of 4 to anything that makes you sleep well (in line 6 above). Now open up Admin web interface to FreePBX. Then choose the Tools tab and click Config Edit.Once phpconfig opens, click on extensions_custom.conf. Add the above code in the [from-internal-custom] context at the top of the file. And click the Update button once you've adjusted the extension number to meet your needs.

Installing MailCall for Asterisk. Now we're ready to install the actual application. Log into your server as root and issue the following commands in order:

cd /var/lib/asterisk/agi-bin
wget http://nerdvittles.com/mailcall/mailcall.zip
unzip mailcall.zip
rm -f mailcall.zip
cp nv-config-555.php nv-config.php
chown asterisk:asterisk nv*.php
chmod 775 nv*.php

Configuring MailCall for Your Email Accounts. The zip file contained two files: nv-mailcall.php (the MailCall for Asterisk 1.4 application) and nv-config-555.php (the email config file for extension 555). And we made a backup copy of the config file: nv-config.php. The important point here is that you must create a config file for each mail account you wish to access, and it must be named correctly, or nothing works. The file name is important because that's how the application retrieves information about your mail account. The file naming syntax is pretty obvious: nv-config-extensiontocall.php. Just make sure your config file name matches the extension you used in the dialplan code above. Once you get the config file named correctly, edit the file and personalize it to your mail settings which we tested with the web interface. Be sure to also replace the phone password entry of 1111 with a four-digit numeric password that you will use to access your email. Save your changes and then reload Asterisk: amportal restart. Now pick up a phone on your Asterisk system and dial 555. Presto! You've got email!

Remote Access to MailCall for Asterisk. You may or may not want access to MailCall from phones outside your Asterisk system. If you do, here's a simple way to implement it. In a nutshell, you'll want to set up an account with a provider such as les.net that provides a DID number with free incoming calls. Or just add an extra DID number to your TelaSIP account. Then add an extension number to your system using freePBX and configure it to always forward calls to 555 or whatever number you used for MailCall. Finally, create a Miscellaneous Destination in FreePBX for extension 555. Then you can tell FreePBX to forward the inbound DID calls to this extension.

Adding Additional Mail Accounts to MailCall for Asterisk. Now you'll want to set up a way for the Little Mrs. to check her email, too. Call it an early Valentine's present. Step 1 is to add 10 more lines of dialplan code (as we did above) to your extensions_custom.conf file using a new extension number, e.g. 556. Second, add a new MailCall config file in /var/lib/asterisk/agi-bin for this extension, e.g. nv-config-556.php. Third, edit the new config file to personalize it to your spouse's email settings and add a dial up password. Finally, restart Asterisk: amportal restart. Now dial the extension and be sure it works. Then you're off to impress the Little Mrs. Enjoy!


FreePBX Training Still A Deal... Until Friday. We raved last week about the upcoming FreePBX Training Seminar, and today we want to add a couple of tidbits for your consideration. In addition to some fantastic training and the fine cuisine of Charleston, rumor has it that you're also going to be treated to some once-in-a-lifetime hardware deals on the very finest Asterisk-compatible hardware cards and servers for your business. If you're a reseller, you can easily cover the cost of your training with the savings you'll realize on these products for your customers. Suffice it to say, you're never going to see comparable prices unless you build the hardware yourself. Without getting anyone in trouble, that's all we can say at this time. You'll just have to trust Uncle Ward on this one. And, the FreePBX Team also has announced that this Friday is the last day for the $600 early-signup discount so don't procrastinate. We're looking forward to meeting all of you and showing you a grand old time in our hometown.

Hosting Provider Special. Just an FYI that the Nerd Vittles hosting provider, BlueHost, has raised the bar again on hosting services. For $6.95 a month, you now can host unlimited domains with 600 gigs of disk storage and 6 terabytes a month of bandwidth. Free domain registration is included for as long as you have an account. Their hosting services are flawless! We oughta know. We've tried the best of them. If you haven't tried a web hosting provider, there's never been a better time. Just use our link. You get a terrific hosting service, and we get a little lunch money for our Birthday Bash.


Some Recent Nerd Vittles Articles of Interest...

Ringbinder theme by Themocracy