Emailing voicemail notifications

In this lesson we will take a look at sending out the voicemail notifications via email to the users created.

Postfix

The software package postfix is by far the most common software used in Linux to send emails. When installing the software, it will ask for what type of email server is being setup. The most common choice is Internet Site. It will then ask for the domain name that will be used in sending emails. This field should already be populated with the hostname of the computer. If you have a domain to use enter it instead of the hostname. For a classroom lab environment the hostname should be fine, it will still send out email, it is just more likely to be sent to a spam folder.

To install postfix use the command:
sudo apt install postfix

With postfix installed, emails should now be sent out whenever a voicemail is left for a user. The voicemail email will either provide a link or attachment for the voicemail audio file.

ISP Problems

Postfix sends out mail on the Simple Mail Transport Protocol (SMTP) port 25. If you are setting Asterisk up at residential account from your Internet Service Provider (ISP) there is a chance they may be blocking outbound email traffic. If this is the case, your emails will be not be sent from the residential location. Most business accounts from the ISP will allow email traffic through.

If the Asterisk server must be ran from a residential account, an option could be used to route traffic through an email service. One example would be to use GMAIL to route SMTP traffic. This option is not covered in this course.

Tips for Spam

As mentioned earlier, without a proper domain name, there is a good chance that the emails will be sent to a spam folder. If you are using a registered domain name there are a few things that can be done to reduce the risk of being sent to spam.

Check the /etc/hosts file to ensure that a fully qualified domain name is used with a loopback address. For example if the servers hostname was ubuntu-asterisk and the domain it belonged to was lecturesnippets.com the following information should be in the file:
127.0.1.1 ubuntu-asterisk.lecturesnippets.com ubuntu-asterisk
127.0.0.1 localhost

Another file to modify includes the /etc/postfix/main.cf file. There is a variable called mydestination that should also have the domain name used in the list. Again, an example of using ubuntu-asterisk as the hostname and lecturesnippets.com as the domain name is listed below:
mydestination = $myhostname, lecturesnippets.com, ubuntu-asterisk.lecturesnippets.com, localhost.lecturesnippets.com, localhost

DNS records are beyond the scope of this lesson. However, there should be an MX record pointing to the asterisk server. In addition to the MX record, there should also be an SPF record indicating that the asterisk server is allowed to send email. This will greatly help with reducing the chance of emails ending up in the spam folder.