Bobcares

How to setup SMTP authentication in Exim4 mail server?

by | Nov 26, 2018

Most ISPs enforce SMTP authentication to send emails which helps them reduce spam.

But, this is not supported by most Linux distributions(Centos, Debian, etc.) by default.

So, you must manually configure your mail server to enable SMTP authentication, which requires many edits in the core configuration files.

In our role as Outsourced Tech Support, we help our web hosts and their Dedicated and VPS customers setup SMTP authentication in their servers.

Today, let’s discuss how we enable SMTP authentication in Exim4 mail server.

Before we get into the details, let’s be clear about SMTP authentication.

 

What is SMTP authentication?

SMTP authentication aka SMTP_AUTH enables an email sender to log on to the mail server using an authentication mechanism supported by the mail server.

In other words, the email client passes the email username and password for each message sent to the mail server.

Therefore, this ensures that every time a message is sent from your account, the mail server confirms that it is authorized to do so.

Now, let’s see the how we configure Exim4 SMTP authentication.

 

How to setup Exim4 SMTP authentication?

Here, we discuss how our Support Engineers configure Exim4 to use SMTP_AUTH with TLS encryption.

 

1) Enable TLS encryption

First, we need to generate an Exim SSL Certificate for use with TLS. We generate the Exim4 SSL certificate with the following command:

/usr/share/doc/exim4-base/examples/exim-gencert

 

This generates the certificate files exim.crt and exim.key in the folder /etc/exim4/.

Further, Exim4 must also be configured to use TLS.

To do this, we create the file(or edit if it exists) “/etc/exim4/exim4.conf.localmacros“, and add the following line.

MAIN_TLS_ENABLE = true

 

Once TLS is enabled, it ensures that all the emails exchanged with the server is in an encrypted connection, to prevent data theft or modification.

 

2) Enable authentication

Next, enable authentication in Exim4, so that server authenticates the email clients each time a message is sent.

To enable plaintext authentication, comment out the following lines in Exim4 configuration file “/etc/exim4/exim4.conf.template

# plain_server:
# driver = plaintext
# public_name = PLAIN
# server_condition = "${if crypteq{$3}{${extract{1}{:}{${lookup{$2}lsearch{CON$
# server_set_id = $2
# server_prompts = :
# .ifndef AUTH_SERVER_ALLOW_NOTLS_PASSWORDS
# server_advertise_condition = ${if eq{$tls_cipher}{}{}{*}}
# .endif

 

Here, the plaintext authenticator supports the authentication mechanisms PLAIN and LOGIN. Both of these transfer data as plain text.

But, don’t worry, we’ve already seen how our Security Specialists, enable SMTP encryption on the server to solve this security issue.

 

3) Setup users and passwords

Additionally, to allow an external mail client to connect to the Exim4 mail server, a new user must be added to Exim4.

We setup new users and passwords with the following command.

/usr/share/doc/exim4-base/examples/exim-adduser

 

This will add the new user and password to the Exim4 password file “/etc/exim4/passwd“.

Most importantly, our Security Specialists ensure that this file is assigned with proper permissions and ownership to prevent outside access.

For instance, on Debian servers, we set the permission and ownership of the “/etc/exim4/passwd” file as follows:

chown root:Debian-exim /etc/exim4/passwd
chmod 640 /etc/exim4/passwd

 

4) Restart Exim4 service

Once you are done with all the above steps, update the Exim4 configuration and restart the service.

We use the below command to generate the main configuration files of Exim4.

update-exim4.conf

 

After that, restart the Exim4 service.

For instance, in Debian servers, we restart the Exim4 service with the below command.

/etc/init.d/exim4 restart

 

You’re done!! Exim4 is now configured to use SMTP authentication.

 

Conclusion

In short, nowadays, most ISPs enforce SMTP authentication to send emails. This is not enabled in most mail servers by default. We have to enable it manually. Today, we have seen the steps followed by our Support Engineers to enable SMTP authentication in Exim4 mail servers.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

SEE SERVER ADMIN PLANS

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

4 Comments

  1. Lous

    I did all the configurations but Exim still allows sending emails without needing to enter a username / password or even with invalid credentials.
    I connect via another server via SMTP and send.

    What can I be doing wrong?

    Reply
    • Maheen Aboobakkar

      Hello Lous,

      If you are still facing the issue, we need to look into the settings. We’ll be happy to talk to you on chat (click on the icon at right-bottom).

      Reply
      • karthik

        Can we have a quick call please

        Reply
        • Hiba Razak

          Hi Karthik,
          Please contact our support team via live chat(click on the icon at right-bottom).

          Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF