Categories
Knowledge Base

Setting up Postfix to use Office 365 mail

FreePBX uses centos 7 and postfix fom its mail delivery, normally this is fine unless the customer is using Office 365 mail then there can be delivery issues.

Firstly you will need to set up a user in Office 365 for the system.

Postfix’s main configuration file is main.cf and that is where we make the required change as follow:

[root@localhost ~]# vi /etc/postfix/main.cf

Append the following lines

masquerade_domains = domainname
myhostname = USERNAME.domainname
mydomain = USERNAME.domainname
myorigin = USERNAME@domainname
relayhost = [smtp.office365.com]:587

mynetworks = 127.0.0.0/8
inet_interfaces = loopback-only
smtp_use_tls = yes
smtp_always_send_ehlo = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_tls_security_level = encrypt
smtp_generic_maps = hash:/etc/postfix/generic 
# smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt

Save and exit from the file.
Next we need to edit the configuration for the postfix SASL credentials:

[root@localhost ~]# vi /etc/postfix/sasl_passwd

Add a line below

[smtp.office365.com]:587 user@domainname:password

Replacing user@domainname:password with your sender account details

Save and exit from file

A Postfix lookup table must now be generated from the sasl_passwd text file by running the following command.

[root@localhost ~]# postmap /etc/postfix/sasl_passwd

Now change permission for this file

[root@localhost ~]# chown root:postfix /etc/postfix/sasl_passwd

[root@localhost ~]# chmod 640 /etc/postfix/sasl_passwd

Next, we need to configure generic file in order to be able to send emails as a valid user (this is required for Office365).

[root@localhost ~]# vi /etc/postfix/generic

Go the end of file and append following lines.

root@localhost.localdomain UserName@Domain.com

Again replacing localhost.localdomain and UserName@Domain.com with your service hostname and the email user are using

Save and exit from file.

Next let’s correct the file permission.

[root@localhost ~]# chown root:root /etc/postfix/generic

[root@localhost ~]# chmod 0600 /etc/postfix/generic

[root@localhost ~]# postmap /etc/postfix/generic

Now restart Postfix service.

[root@localhost ~]# systemctl restart postfix

Now try to send a test email using the command below:
FOR Centos:

echo "This is the body of the email"| mail -r"Sender-Display-Name<sender@domain.com>" -s "This is the subject(E-Mail from SMTP Relay) line" recipeat@gmail.com

In FreePBX under Voicemail admin you must change the senders address to match your account as well as the sender for notifications such as backups etc. otherwise you can get errors and mail wont be delivered.

Categories
Elastix Support Knowledge Base Technical

Setting the server domain in elastix correct for scripted email

We run many scripts on customer servers to email cdrs, backups etc, one problem with some mail servers is the mail gets rejected as it comes from root@elastixserver.yourdomain.com by default to fix this is simple and only takes a few lines.

Postfix MTA offers smtp_generic_maps parameter. You can specify lookup tables that replace local mail addresses by valid Internet addresses when mail leaves the machine via SMTP.

Open your main.cf file

# vi /etc/postfix/main.cf

Append following parameter

smtp_generic_maps = hash:/etc/postfix/generic

Save and close the file. Open /etc/postfix/generic file:

# vi /etc/postfix/generic

Make sure root@elastixserver.yourdomain.com change to elastixserver@yourdomain.com add :

root@elastixserver.yourdomain.com  elastixserver@yourdomain.com

Save and close the file. Create or update generic postfix table:

# postmap /etc/postfix/generic

Restart postfix:

# /etc/init.d/postfix restart

When mail is sent to a remote host via SMTP this replaces root@elastixserver.yourdomain.com by elastixserver@yourdomain.com mail address. You can use this trick to replace address with your ISP address if you are connected via local SMTP.

To set up gmail for delivery look at this

Categories
Knowledge Base

Getting bad ELF interpreter with Nagios

When using some Nagios plugins to check server load and disk space on 64bit systems you may get back

/lib/ld-linux.so.2: bad ELF interpreter: No such file or directory

This means that you dont have the required libraries, To install them on Centos

yum install glibc.i686

The solution above works on CentOS, Fedora, or Red Hat 64bit operating systems; on a Debian or Ubuntu derived system use :

 sudo apt-get install ia32-libs