Report this

What is the reason for this report?

Enable authentication on postfix

Posted on July 24, 2016

i have installed postfix on ubuntu server 14.04.4. i am able to telnet to the server as send emails from my smtp server. but since there is no authentication needed for this everybody is having access to the server. so,

  1. how to setup authentication. i would like username password way
  2. can i use local ubuntu account use for the authentication.


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

You have an article about it on DO : https://www.digitalocean.com/community/tutorials/how-to-configure-a-mail-server-using-postfix-dovecot-mysql-and-spamassassin

Uses dovecot and mysql for TLS authentication.

Append these lines in /etc/postfix/main.cf and restart postfix service.

smtp_tls_auth_only = yes smtp_tls_security_level = encrypt

The email messages i’ll be encrypted as TLS and verified by your hostname.

Enabling authentication on Postfix involves configuring Postfix to use SASL (Simple Authentication and Security Layer) for authentication, and typically Dovecot is used as the SASL provider. Below are the steps to enable authentication on Postfix using Dovecot on a Debian-based system such as Kali Linux. This guide assumes you have both Postfix and Dovecot installed.

Step-by-Step Guide

1. Install Necessary Packages

Ensure that both Postfix and Dovecot are installed:

sudo apt update
sudo apt install postfix dovecot-core dovecot-imapd dovecot-pop3d

2. Configure Dovecot for SASL

Edit the Dovecot configuration to enable SASL:

sudo nano /etc/dovecot/conf.d/10-auth.conf

Uncomment and modify the following lines:

disable_plaintext_auth = no
auth_mechanisms = plain login

Edit the Dovecot configuration to set up the auth socket:

sudo nano /etc/dovecot/conf.d/10-master.conf

Uncomment and modify the unix_listener section:

service auth {
    unix_listener /var/spool/postfix/private/auth {
        mode = 0660
        user = postfix
        group = postfix
    }
}

Restart Dovecot to apply the changes:

sudo systemctl restart dovecot

3. Configure Postfix to Use Dovecot for SASL

Edit the Postfix main configuration file:

sudo nano /etc/postfix/main.cf

Add or modify the following lines to enable SASL and configure it to use Dovecot:

smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination

# TLS settings (optional but recommended)
smtpd_tls_cert_file = /etc/ssl/certs/your_cert.pem
smtpd_tls_key_file = /etc/ssl/private/your_key.pem
smtpd_use_tls = yes

Restart Postfix to apply the changes

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.