+91 88 00 563434 [email protected] Blog open-book Knowledge Base

Find Solutions in Our Knowledge Base

What is Sendmail? Sendmail Configuration and Details

You are here:
Sharing is Caring

Have you ever heard about Sendmail? If you are running a cPanel website, you should be familiar with the Exim and you may know how Mail Transfer Agent (MTA) works. As cPanel has become the most popular control panel,  Exim has become the popular MTA. cPanel has Exim as the default MTA. Even for those who don’t use a control panel will compile Exim as their mail server. There exist other Mail Transfer Agents in the web hosting industry. Sendmail is an MTA just like Exim, and is the most popular Unix-based implementation of the SMTP protocol for the email transmission. Just like other mail servers, Sendmail will try to deliver the incoming emails to the recipient end immediately. As in the case of exim, we need to use a Mail Delivery Agent (MDA) with POP3 of IMAP protocol.

Sendmail is a descendant of the deliver mail program written by Eric Allman. Allman wrote the ARPANET deliver mail which was shipped in 1979. He wrote Sendmail as a derivative of deliver mail in the early 1980s at UC Berkeley. It shipped with BSD 4.1c in 1983, and it was the first BSD version which included TCP/IP protocols.

 How to configure the Sendmail?

Let’s have a look on how to configure the Sendmail. Before seeing the configuration setting, first we need to look on the working of configuration file. Please be aware that the configuration file of Sendmail is sendmail.cf. This file is a product of the macro configuration file, sendmail.mc and you have to make configuration changes on the macro file. The changes made directly to the sendmail.cf file may not be reflected in the live environment. However, sometimes it will work. So that, It is not recommended that performing changes on the sendmail.cf file directly. Once you change the macro file, it will be resulting in the change in .cf file. There are prewritten macros in the sendmail.mc file which will create the sendmail.cf file. These will be present in the directory “cf”. The custom macros are kept in a directory “cf/cf”. The macro file will be parsed against the other m4 scripts, resulting in the creation of sendmail.cf file. In short, the creation of sendmail.cf can be explained as follows:

m4 ../m4/cf.4 sendmail.mc > sendmail.cf

This is how to create a Sendmail configuration file, sendmail.cf. The contents of a sample sendmail.cf file is provided below.

VERSIONID(`this is my custom sendmail.mc for linux – 201209302222′)dnl

OSTYPE(`linux’)dnl

DOMAIN(`generic’)dnl

undefine(`BITNET_RELAY’)dnl

undefine(`DECNET_RELAY’)dnl

undefine(`FAX_RELAY’)dnl

undefine(`UUCP_RELAY’)dnl

define(`confSMTP_LOGIN_MSG’,`$j’)dnl

define(`confCF_VERSION’,`0′)dnl

define(`confTO_IDENT’,`0′)dnl

define(`confMAX_MESSAGE_SIZE’,`2048000′)dnl

define(`confLOG_LEVEL’,`1′)dnl

define(`confPRIVACY_FLAGS’,`goaway,noexpn,novrfy,noetrn,noverb,nobodyreturn,needmailhelo,restrictmailq,restrictqrun’)dnl

define(`confAUTH_OPTIONS’,`ABEX’)dnl

dnl define(`confSMART_HOST’,`your.upstream.isp.smtp.service.tld’)dnlTURE(`access_db’,`hash -T <TMPF> /etc/mail/access’)dnl

FEATURE(`nouucp’,`reject’)dnl

FEATURE(`use_cw_file’)dnl

FEATURE(`use_ct_file’)dnl

FEATURE(`virtusertable’,`hash /etc/mail/virtusertable’)dnl

FEATURE(`mailertable’,`hash /etc/mail/mailertable’)dnl

FEATURE(`genericstable’,`hash /etc/mail/genericstable’)dnl

FEATURE(`domaintable’,`hash /etc/mail/genericstable’)dnl

FEATURE(`relay_hosts_only’)dnl

FEATURE(`smrsh’)dnl

FEATURE(`blacklist_recipients’)dnl

FEATURE(`masquerade_envelope’)dnl

MASQUERADE_DOMAIN(`myolddomain.tld’)dnlQUERADE_AS(`my.extenalname.tld’)dnlOSED_USER_FILE(`/etc/mail/exposed-users’)dnl

MAILER(smtp)dnl

MAILER(local)dnl

Now, let’s see the explanation of the above contents.

In Red Hat, the sendmail.cf file comes with an include reference. It will show the following:

include(`../m4/cf.m4′)dnl

Typically the configuration file for Sendmail will be starting with the version ID.

VERSIONID(`This is my custom configuration for Sendmail v0.1′)dnl

The next line will provide you the information about the OS. It will be as below.

OSTYPE(`linux’)dnl

The various OS type are Linux, hpux11, aix5, etc.

The next line is the domain specific settings. This will be as the following.

DOMAIN(`generic’)dnl

This line is used to apply the domain specific configurations particular to your domain. The ‘generic’ is a profile which will allow the standard mail functionality for IPv4.

There are many features that Sendmail supports. We can disable the unwanted features to ensure greater security. To disable the feature, you should use the undefine as shown below.

undefine(`BITNET_RELAY’)dnl

undefine(`DECNET_RELAY’)dnl

undefine(`FAX_RELAY’)dnl

The next lines indicate how to mask the identity of the server.

define(`confSMTP_LOGIN_MSG’,`$j’)dnl

define(`confCF_VERSION’,`0′)dnl

This includes masking the implementation and versioning of this release. To mask the versioning of the release, we need to clear the help file. This can be achieved with the following command.

# echo ” ” > /etc/mail/helpfile

The daemon options can be set with the following options.

DAEMON_OPTIONS(`M=AE’)dnl

The options possible here are:

a – always require authentication

b – bind to interface through which mail has been received

c – perform hostname canonifcation (.cf)

f – require fully qualifed hostname (.cf)

s – Run smtps (SMTP over SSL) instead of smtp

u – allow unqualifed addresses (.cf)

A – disable AUTH (overrides ’’a’’ modifer)

C – don’’t perform hostname canonifcation

E – disallow ETRN (see RFC 2476)

O – optional; if opening the socket fails ignore it

S – don’’t offer STARTTLS

We can masquerade the domain with the following line.

MASQUERADE_DOMAIN(`myolddomain.tld’)dnl

Next section is the mailer section. This section defines the local transports available and the order in which the transports are used. This can be set with the following line.

MAILER(`smtp’)dnl

You can use the following options for SMTP.

“smtp” to do regular SMTP

“esmtp” to do ESMTP

“smtp8” to do 8bit MIME

“dsmtp” to do on demand delivery

“relay” for transmission to the RELAY_HOST, LUSER_RELAY, or MAIL_HUB.


Sharing is Caring

Leave a Comment

Table of Contents