Mar
06
2009




Asterisk Voicemail to Email solved with Postfix

A while back I wrote an article for asteriskvoipnews.com about routing loops occurring from misconfigured DNS(or lack there of). My article was about routing loops caused by Asterisk attempting to send mail outside the network when the mail server destination is internal. To correct this issue the Asterisk PBX needs to define a ‘mail relay'(mail relay) on the internal network. This post will discuss using Postfix as an alternative to Sendmail for this purpose.

The goals of this post:

– explain Asterisk voicemail to email routing loops

– LAB: Install Postfix and configure ‘smarthost’ for mail relay

Here is an excerpt from my previous post that explains the nature of the problem:

One of the most popular features in Asterisk is the Voice Mail to email feature. It’s fairly straight forward to set up as far as Asterisk is concerned, but many people (including myself) have run into a situation where the Asterisk server is on the same internal network as the mail server. When Asterisk resolves somebody@somecompany.com , it attempts to send the mail to the Fully Qualified Domain Name (FQDN).

In the example above this might be something like 216.39.144.X. This works great if you have hosted email outside your network, or you have internal DNS to send the mail originating inside the network to the correct host. However many small to medium size businesses either don’t have internal DNS or don’t know how to set it up correctly.

The result is that the VM attachment is being sent outside the network and can’t get back because of a routing loop. This discussion isn’t about routing loops, just trust me that sending out packets out of your network when the destination is on the inside causes problems.

Solving Asterisk PBX Voice Mail to Email Name Resolution Issues

Since I wrote that help article I have found Postfix to be a much better way to specify an internal mail server. Postfix is simple and easy to configure. Troubleshooting and recompiling the sendmail database is annoying and difficult task for newbies. Postfix requires one edit to, ‘/etc/postfix/’ and a reload. Eats routing loop’s for breakfast!

LAB: Install Postfix and configure ‘smarthost’ for mail relay

Lets start off by removing our old mail transport agent, sendmail.

[root@mattopia ~]# yum remove sendmail

Now install postfix.

[root@mattopia ~]# yum install postfix

Make sure Postfix starts at boot with the chkconfig command.

[root@mattopia ~]# chkconfig –level 3 postfix on

Find the ‘relayhost’ section below.  Uncomment the line and add the internal IP address of your mail server.  This will prevent Asterisk from sending the voicemail attachments to the public IP.  Routing loop circumvented.

#INTERNET OR INTRANET
# The relayhost parameter specifies the default host to send mail to
# when no entry is matched in the optional transport(5) table. When
# no relayhost is given, mail is routed directly to the destination.
#
# On an intranet, specify the organizational domain name. If your
# internal DNS uses no MX records, specify the name of the intranet
# gateway host instead.
#
# In the case of SMTP, specify a domain, host, host:port, [host]:port,
# [address] or [address]:port; the form [host] turns off MX lookups.
#
# If you’re connected via UUCP, see also the default_transport parameter.
#
#relayhost = $mydomain
#relayhost = [gateway.my.domain]
#relayhost = [mailserver.isp.tld]
#relayhost = uucphost
#relayhost = [an.ip.add.ress]

[root@fc-test1 ~]# nano /etc/postfix/main.cf

# INTERNET OR INTRANET
# The relayhost parameter specifies the default host to send mail to
# when no entry is matched in the optional transport(5) table. When
# no relayhost is given, mail is routed directly to the destination.
#
# On an intranet, specify the organizational domain name. If your
# internal DNS uses no MX records, specify the name of the intranet
# gateway host instead.
#
# In the case of SMTP, specify a domain, host, host:port, [host]:port,
# [address] or [address]:port; the form [host] turns off MX lookups.
#
# If you’re connected via UUCP, see also the default_transport parameter.
#
#relayhost = $mydomain
#relayhost = [gateway.my.domain]
#relayhost = [mailserver.isp.tld]
#relayhost = uucphost
relayhost = 192.168.1.10

Now start postfix.

[root@fc-test1 ~]# service postfix start
Starting postfix:                                          [  OK  ]

In conclusion I’d like to point out that Postfix is easy to install and easy to use.  One note, if you need to leave sendmail installed to satisfy other dependencies that’s okay.  Just make sure to turn it off at boot.

If you like this article tell Google!!









Written by mattb in: Asterisk,Asterisk Post | Tags: , , , , ,

No Comments »

RSS feed for comments on this post. TrackBack URL

Leave a comment