postfix mail server

Postfix email forward

On an Ubuntu Server, i done following to setup email forwarding.

Install postfix

Edit /etc/postfix/main.cf, add following

Add

Create Virtual mailbox

Add

Create alias file, used for mail forwarding

Add

Wth above configuration, mail coming to [email protected]_HERE.com will get forwarded to [email protected] Email coming to [email protected]_HERE.com get delivered to local mailbox folder.

Now run following commands to make hashmap

Restart postfix

iredmail increase mail attachment size

Default mail attachment size in iredmail is 10 MB. To increase mail attachment size, login to server as user root, run following commands

Here 104857600 is 100 MB in bytes (100 * 1024 * 1024). Change this as required. Sending very large file using mail attachment is not recommended, it is better use file sharing services like Google Drive, Dropbox, Microsoft OneDrive or another file hosting service for sharing large files.

Now edit php.ini file

Change value for 3 of the following settings. It can be anything above 100 MB or whatever attachment size you want to use.

Restart php-fpm

Edit roundcube configuration file

Set value for

Edit Nginx config file

Set value for

restart nginx

Postfix disable IPv6

To disable IPv6 on postfix mail server, edit

Find

Replace with

Restart postfix

Method 2

Configure postfix to relay mails using Gmail

Install postfix

Create file

Add

Save and exit editor. Run

Edit postfix configuration file

Find and remove

At end of the file, add

Restart postfix

Now all mails will be forwarded using gmail.

Test Email Delivery

Install mailutils

To sent test email, run

Check mail log

See postfix

Configure Postfix to use Amazon SES

Install postfix with

Update postfix config with

Edit

Add to end of the file

In the above, replace SMTP_SERVER_NAME with your Amazon SES mail server, for example “email-smtp.us-east-1.amazonaws.com”, you can see it in your Amazon SES console.

Run

Replace SMTP_SERVER_NAME, SMTP_USERNAME and SMTP_PASSWORD with your actual credentials.

Now run

Restart postfix

You can test mail working with

For sending from Apache, you may need to set myorigin in postfix confgiration with your veirfied domain. This can be done by editing

You can verify myorgin with

Sending Mail from Amazon EC2

When sending email from Amazon EC2, it rejected with

Problem is solved by editing

Find

Replace with

Amazon SES

elasticemail postfix

Configure ElasticEmail with Postfix

To configure ElasticEmail with postfix, first install sasl support

On Debian/Ubuntu

On RHEL/CentOS

Edit postfix config

On Ubuntu/Debian, you need to comment the line starting with “relayhost”.

Add following

Now create file

Add following content

You can find your SMTP user name and password from

https://elasticemail.com/account/#/settings/apiconfiguration

elasticemail postfix

Now run

Restart postfix with

Postfix will relay mails using postfix now.

See postfix

Configure Postfix to sent emails using MailGun

First install requirements

Run

Edit /etc/postfix/main.cf

Add

Create file /etc/postfix/sasl_passwd

Replace SMTP_LOGIN and SMTP_PASSWORD with your user and password you get from mailgun.

Run

Restart postfix

You can test email with

SASL authentication no mechanism available

When sending email from postfix mail sever that use mailgun for relaying mails, i get error

Jan 4 03:16:06 serverok-vm postfix/qmgr[22652]: 795731A8D: from=, size=820, nrcpt=1 (queue active)
Jan 4 03:16:06 serverok-vm postfix/smtp[24050]: warning: SASL authentication failure: No worthy mechs found
Jan 4 03:16:06 serverok-vm postfix/smtp[24050]: 795731A8D: SASL authentication failed; cannot authenticate to server smtp.mailgun.org[34.237.7.101]: no mechanism available
Jan 4 03:16:06 serverok-vm postfix/smtp[24050]: warning: SASL authentication failure: No worthy mechs found
Jan 4 03:16:06 serverok-vm postfix/smtp[24050]: 795731A8D: SASL authentication failed; cannot authenticate to server smtp.mailgun.org[34.232.180.42]: no mechanism available
Jan 4 03:16:06 serverok-vm postfix/smtp[24050]: warning: SASL authentication failure: No worthy mechs found

On checking postfix mail queue, the mail is stuck in queue

The problem is fixed by installing libsasl2-modules.

On Debian/Ubuntu

On RHEL/CentOS

Now restart postfix.