Showing posts with label postfix. Show all posts
Showing posts with label postfix. Show all posts

Monday, June 17, 2013

How to configure Postfix to send mail via Google Apps

In this tutorial, we’ll configure Postfix to send an email through Google’s SMTP on Ubuntu 12.04 LTS Server for Google Apps. We can use the exact same setup for Gmail account also:

google-apps

Install Postfix and command line mail utility using the following command:
sudo apt-get install postfix mailutils

1

Backup the default configuration file for postfix:
sudo cp /etc/postfix/main.cf /etc/postfix/main.cf.bk

1a

Edit the /etc/postfix/main.cf file:
sudo nano /etc/postfix/main.cf

2

Delete everything from main.cf file and add this:
smtp_sasl_security_options = noanonymous
relayhost = [smtp.gmail.com]:587
smtp_use_tls = yes
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/googleapps/password

3

Create a directory googleapps under /etc/postfix:
sudo mkdir /etc/postfix/googleapps

4

Move to the /etc/postfix/googleapps directory:
cd /etc/postfix/googleapps/

5

Create a file named password inside /etc/postfix/googleapps directory:
sudo nano password

6

Add the following contents to the password file:
[smtp.gmail.com]:587 arbab.nazar@rbgeek.com:password

7

Note: arbab.nazar@rbgeek.com is a Google apps mail address of mine with false password, you can use your original Google apps email address and password here.

Change the permission on password file:
sudo chmod 600 password

8

Transform the password file into a hashed table:
sudo postmap password

9

Copy CA root certificates to postfix directory:
sudo cp /etc/ssl/certs/ca-certificates.crt /etc/postfix/cacert.pem

10

Restart the postfix service:
sudo /etc/init.d/postfix restart

11

Test the postfix server by sending an email to another account:
echo "Testing" | mail -s "Email from tendo" arbabnazar@ymail.com

12

Check the destination email account:

13

Hope this will help you!

How to Fix Postfix File too large error

Today, I was getting an error from my Postfix mail server, when trying to send mysqldump file which is about 8 MB attachment. I checked the /var/log/maillog and found this:
sudo tail -f  /var/log/maillog

1

To view the default settings for all the parameters of Postfix:
postconf -d | grep size

2

 

These size values surprised me because I didn’t include any limits on email sizes in /etc/postfix/main.cf file but the Google search revealed me that according to Postfix the default value for a mailbox size is 51200000 bytes and max message size is 10240000 bytes.

Note: MIME encoding adds a 33.33% overhead to an attachment (3 bytes turn into 4 bytes). With a message size limit of 10 MB, the max attachment size is around 7 MB.

To resolve this issue, the maximum outgoing message size needs to be increased as well as the mailbox size. Enter the following commands(0 mean unlimited, adjust it according to your need):
sudo postconf -e mailbox_size_limit=0
sudo postconf -e message_size_limit=0

3

After that, restart the Postfix service:
sudo /etc/init.d/postfix restart

4

Hope this will help you!