This is for asterisk now version 3.0
Postfix is already installed on asterisk now 3.x iso
Configure postfix
Postfix configuration happens in /etc/postfix/main.cf. Essentially, any parameter starting smtp_ relates to postfix sending email. Any starting smtpd_ relates to it receiving mail for sending on. For this exercise we want to disable the receipt of mail (apart from over the loopback interface).
The sections below show you why to make changes, and the attached main.txt, which you should rename to main.cf, shows the finished file.
Error Notices
These notices will email
delay_warning_time = 2h bounce_notice_recipient =This email address is being protected from spambots. You need JavaScript enabled to view it. delay_notice_recipient =This email address is being protected from spambots. You need JavaScript enabled to view it. error_notice_recipient =This email address is being protected from spambots. You need JavaScript enabled to view it.
Only allow mail to be sent, not received
We only want to send mail from our mail servers, we don’t want to receive it. Here’s how:
myhostname = yourdomain.com alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases mydomain = yourdomain.com myorigin = yourdomain.com mydestination = mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = 127.0.0.1 inet_protocols = ipv4
SSL
These lines enable SSL and set up the config:
smtp_use_tls=yes smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache smtp_sasl_tls_security_options = noanonymous tls_random_source = dev:/dev/urandom
Authentication
Finally, we want to log in to 1and1′s servers to send the email. Here’s the configuration settings:
smtp_sasl_auth_enable = yes relayhost=[smtp.1and1.com]:587 smtp_sasl_password_maps=hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = noanonymous
Creating the password file
The “smtp_sasl_password_maps” configuration option above sets a file which will contain the username & password used to log on to 1and1. To do this, first of all, we create the file:
sudo su echo '' > /etc/postfix/sasl_passwd chown root.root /etc/postfix/sasl_passwd chmod 600 /etc/postfix/sasl_passwd nano /etc/postfix/sasl_passwd
Now we need to put the username & password in there. It’s of the form:
[smtp.1and1.com]:587This email address is being protected from spambots. You need JavaScript enabled to view it. :password
The email address (
You should then save the file, and encrypt it as follows:
postmap /etc/postfix/sasl_passwd
And then check:
postfix check
And restart postfix:
/etc/init.d/postfix restart
Testing postfix
To test postfix is working, try:
echo "Subject: Test"| sendmail -fThis email address is being protected from spambots. You need JavaScript enabled to view it. -vThis email address is being protected from spambots. You need JavaScript enabled to view it.
And then:
sudo tail -f /var/log/mail.log
to check that the email has been sent ok.