Sendmail is an MTA, meaning it accepts email messages sent to it using the SMTP proto-
col and transports them to another MTA email server until the messages reach their destinations. It also accepts email for the local network and delivers them to local mail spools, one for each user.

1.Mail User Agent(MUA)
A client used to compose and read e-mail(outlook,evolution,thunderbird,mutt)

2.Mail Transfer Agent(MTA)
An SMTP server used to relay or accept e-mail for delivery(posfix,sendmail,exim,qmail,exchange    server)

3.Mail Delivery Agent(MDA)
A program used by the final MTA to deliver e-mail to the  message store May be included with the  MTA or a separate  program such as procmail.

4.Mail Access Agent(MAA)
An IMAP/POP3 server used by an MUA to access the message store(Dovecot,Cyrus IMAP)

[root@mail ~]# yum install m4 telnet mailx sendmail sendmail-cf

[root@mail ~]# service sendmail start
Starting sendmail:                                         [  OK  ]

[root@mail ~]# ps -ef | grep sendmail
root       2539      1  0 04:35 ?        00:00:00 sendmail: accepting connections
smmsp      2556      1  0 04:36 ?        00:00:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
root       2685   2481  0 04:38 pts/1    00:00:00 grep sendmail

[root@mail ~]# netstat -tlpn | grep 25
tcp        0      0      *                   LISTEN      2539/sendmail

[root@mail ~]# rpm -qa sendmail*

[root@mail ~] # chkconfig sendmail on

[root@mail ~] # chkconfig –list sendmail
sendmail       0:off 1:off 2:on 3:on 4:on 5:on 6:off

[root@mail ~] # ls -l /etc/mail
total 192
-rw-r–r–. 1 root root   469 Feb  4  2015 access
-rw-r—–. 1 root root 12288 Mar 24 20:41 access.db
-rw-r–r–. 1 root root     0 Mar 24 20:42 aliasesdb-stamp
-rw-r–r–. 1 root root   233 Feb  4  2015 domaintable
-rw-r—–. 1 root root 12288 Mar 24 20:41 domaintable.db
-rw-r–r–. 1 root root  5584 Feb  4  2015 helpfile
-rw-r–r–. 1 root root    75 Mar 24 21:01 local-host-names
-rw-r–r–. 1 root root   997 Feb  4  2015 mailertable
-rw-r—–. 1 root root 12288 Mar 24 20:41 mailertable.db
-rwxr-xr-x. 1 root root  2700 Feb  4  2015 make
-rw-r–r–. 1 root root    92 Feb  4  2015 Makefile
-rw-r–r–. 1 root root 58596 Mar 24 20:55
-rw-r–r–. 1 root root  7202 Feb  4  2015
-rw-r–r–. 1 root root 41521 Feb  4  2015
-rw-r–r–. 1 root root   941 Feb  4  2015
-rw-r–r–. 1 root root   127 Feb  4  2015 trusted-users
-rw-r–r–. 1 root root  1847 Feb  4  2015 virtusertable
-rw-r—–. 1 root root 12288 Mar 24 20:41 virtusertable.db

[root@mail mail]# cat access
# Check the /usr/share/doc/sendmail/ file for a description
# of the format of this file. (search for access_db in that file)
# The /usr/share/doc/sendmail/ is part of the sendmail-doc
# package.
# If you want to use AuthInfo with “M:PLAIN LOGIN”, make sure to have the
# cyrus-sasl-plain package installed.
# By default we allow relaying from localhost…
Connect:localhost.localdomain RELAY
Connect:localhost RELAY
Connect: RELAY
[root@mail mail]# cat access.db
a r*�
[root@mail mail]# cat aliasesdb-stamp
[root@mail mail]# cat domaintable
# The “domain table” can be used to provide domain name mapping.
# Use of this should really be limited to your own domains.
# It may be useful if you change names (e.g., your company
# changes names from to
[root@mail mail]# cat domaintable.db
[root@mail mail]# cat helpfile
#vers 2
cpyr Copyright (c) 1998-2000, 2002, 2004-2007 Sendmail, Inc. and its suppliers.
cpyr All rights reserved.
cpyr Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
cpyr Copyright (c) 1988, 1993
cpyr The Regents of the University of California. All rights reserved.
cpyr By using this file, you agree to the terms and conditions set
cpyr forth in the LICENSE file which can be found at the top level of
cpyr the sendmail distribution.
smtp This is sendmail
smtp Topics:
smtp For more info use “HELP <topic>”.
smtp To report bugs in the implementation see
smtp For local information send email to Postmaster at your site.
help HELP [ <topic> ]
help The HELP command gives help info.
helo HELO <hostname>
helo Introduce yourself.
ehlo EHLO <hostname>
ehlo Introduce yourself, and request extended SMTP mode.
ehlo Possible replies include:
ehlo SEND Send as mail [RFC821]
ehlo SOML Send as mail or terminal [RFC821]
ehlo SAML Send as mail and terminal [RFC821]
ehlo EXPN Expand the mailing list [RFC821]
ehlo HELP Supply helpful information [RFC821]
ehlo TURN Turn the operation around [RFC821]
ehlo 8BITMIME Use 8-bit data [RFC1652]
ehlo SIZE Message size declaration [RFC1870]
ehlo VERB Verbose [Allman]
ehlo CHUNKING Chunking [RFC1830]
ehlo BINARYMIME Binary MIME [RFC1830]
ehlo PIPELINING Command Pipelining [RFC1854]
ehlo DSN Delivery Status Notification [RFC1891]
ehlo ETRN Remote Message Queue Starting [RFC1985]
ehlo STARTTLS Secure SMTP [RFC2487]
ehlo AUTH Authentication [RFC2554]
ehlo ENHANCEDSTATUSCODES Enhanced status codes [RFC2034]
ehlo DELIVERBY Deliver By [RFC2852]
mail MAIL From:<sender> [ <parameters> ]
mail Specifies the sender. Parameters are ESMTP extensions.
mail See “HELP DSN” for details.
rcpt RCPT To:<recipient> [ <parameters> ]
rcpt Specifies the recipient. Can be used any number of times.
rcpt Parameters are ESMTP extensions. See “HELP DSN” for details.
data DATA
data Following text is collected as the message.
data End with a single dot.
rset RSET
rset Resets the system.
quit QUIT
quit Exit sendmail (SMTP).
auth AUTH mechanism [initial-response]
auth Start authentication.
starttls STARTTLS
starttls Start TLS negotiation.
verb VERB
verb Go into verbose mode. This sends 0xy responses that are
verb not RFC821 standard (but should be) They are recognized
verb by humans and other sendmail implementations.
vrfy VRFY <recipient>
vrfy Verify an address. If you want to see what it aliases
vrfy to, use EXPN instead.
expn EXPN <recipient>
expn Expand an address. If the address indicates a mailing
expn list, return the contents of that list.
noop NOOP
noop Do nothing.
send SEND FROM:<sender>
send replaces the MAIL command, and can be used to send
send directly to a users terminal. Not supported in this
send implementation.
soml SOML FROM:<sender>
soml Send or mail. If the user is logged in, send directly,
soml otherwise mail. Not supported in this implementation.
saml SAML FROM:<sender>
saml Send and mail. Send directly to the user’s terminal,
saml and also mail a letter. Not supported in this
saml implementation.
turn TURN
turn Reverses the direction of the connection. Not currently
turn implemented.
etrn ETRN [ <hostname> | @<domain> | \#<queuename> ]
etrn Run the queue for the specified <hostname>, or
etrn all hosts within a given <domain>, or a specially-named
etrn <queuename> (implementation-specific).
dsn MAIL From:<sender> [ RET={ FULL | HDRS} ] [ ENVID=<envid> ]
dsn [ ORCPT=<recipient> ]
dsn SMTP Delivery Status Notifications.
dsn Descriptions:
dsn RET Return either the full message or only headers.
dsn ENVID Sender’s “envelope identifier” for tracking.
dsn NOTIFY When to send a DSN. Multiple options are OK, comma-
dsn delimited. NEVER must appear by itself.
dsn ORCPT Original recipient.
-bt Help for test mode:
-bt ? :this help message.
-bt .Dmvalue :define macro `m’ to `value’.
-bt .Ccvalue :add `value’ to class `c’.
-bt =Sruleset :dump the contents of the indicated ruleset.
-bt =M :display the known mailers.
-bt -ddebug-spec :equivalent to the command-line -d debug flag.
-bt $$m :print the value of macro $$m.
-bt $$=c :print the contents of class $$=c.
-bt /mx host :returns the MX records for `host’.
-bt /parse address :parse address, returning the value of crackaddr, and
-bt the parsed address.
-bt /try mailer addr :rewrite address into the form it will have when
-bt presented to the indicated mailer.
-bt /tryflags flags :set flags used by parsing. The flags can be `H’ for
-bt Header or `E’ for Envelope, and `S’ for Sender or `R’
-bt for Recipient. These can be combined, `HR’ sets
-bt flags for header recipients.
-bt /canon hostname :try to canonify hostname.
-bt /map mapname key :look up `key’ in the indicated `mapname’.
-bt /quit :quit address test mode.
-bt rules addr :run the indicated address through the named rules.
-bt Rules can be a comma separated list of rules.
control Help for smcontrol:
control help This message.
control restart Restart sendmail.
control shutdown Shutdown sendmail.
control status Show sendmail status.
control mstat Show sendmail status (machine readable format).
control memdump Dump allocated memory list (for debugging only).
[root@mail mail]# cat local-host-names
# local-host-names – include all aliases for your machine here.
[root@mail mail]# cat mailertable
# The “mailer table” can be used to override routing for particular domains
# (which are not in class {w}, i.e. local host names).
# hash /etc/mail/mailertable
# Keys in this database are fully qualified domain names or partial domains
# preceded by a dot — for example, “vangogh.CS.Berkeley.EDU” or
# “.CS.Berkeley.EDU”. As a special case of the latter, “.” matches any domain
# not covered by other keys. Values must be of the form:
# mailer:domain
# where “mailer” is the internal mailer name, and “domain” is where to send
# the message. These maps are not reflected into the message header. As a
# special case, the forms:
# local:user
# will forward to the indicated user using the local mailer,
# local:
# will forward to the original user in the e-mail address using the local
# mailer, and
# error:code message
# error:D.S.N:code message
# will give an error message with the indicated SMTP reply code and message,
# where D.S.N is an RFC 1893 compliant error code.
[root@mail mail]# cat mailertable.db

[root@mail mail]# cat make
# Generate db and cf files if necessary. This used to be handled by
# /etc/mail/Makefile.

teste() {
if ! test -e “$1”; then
echo “$1 doesn’t exist”
exit 2

makedb() {
teste “${1%.db}”

if [ -z “$SM_FORCE_DBREBUILD” ]; then
test “${1%.db}” -nt “$1” || return 0

if [ “$1” = userdb.db ]; then
makemap btree “$1” < “${1%.db}”
makemap hash “$1” < “${1%.db}”

makealiasesdb() {

if [ -z “$SM_FORCE_DBREBUILD” ]; then
files=$(grep ‘^O AliasFile=’ |
while read a; do echo ${a#*=}; done)

for a in $files; do
if [ “$a” = /etc/aliases ]; then
# /etc/aliases.db may be used by other MTA, make sure nothing
# has touched it since our last newaliases call
test “$a” -nt “${a}.db” ||
test aliasesdb-stamp -nt “${a}.db” ||
test aliasesdb-stamp -ot “${a}.db” || continue
test “$a” -nt “${a}.db” || continue


[ $uptodate = 1 ] && return 0

# check if alternatives is configured to sendmail
if [ “$(readlink -e /usr/bin/newaliases)” = /usr/sbin/sendmail.sendmail ]
/usr/bin/newaliases > /dev/null
touch -r /etc/aliases.db aliasesdb-stamp 2> /dev/null
rm -f aliasesdb-stamp

makecf() {

teste “$mc”

if [ -z “$SM_FORCE_CFREBUILD” ]; then
test “$mc” -nt “$1” || return 0

if test -f /usr/share/sendmail-cf/m4/cf.m4; then
umask 022
[ -e “$1” ] && mv -f “$1” “$1”.bak
m4 “$mc” > “$1”
echo “WARNING: ‘$mc’ is modified. Please install package sendmail-cf to update your configuration.”
exit 15

makeall() {
# These could be used by sendmail, but are not part of the default install.
# To use them you will have to generate your own with
# FEATURE(‘whatever’)
test -f bitdomain && makedb bitdomain.db
test -f uudomain && makedb uudomain.db
test -f genericstable && makedb genericstable.db
test -f userdb && makedb userdb.db
test -f authinfo && makedb authinfo.db

makedb virtusertable.db
makedb access.db
makedb domaintable.db
makedb mailertable.db


cd /etc/mail || exit 1

[ $# -eq 0 ] && makeall

for target; do
case “$target” in
makedb “$target”
makecf “$target”
rm -f *.db *~ aliasesdb-stamp
service sendmail “$target”
echo “Don’t know how to make $target”
exit 2

[root@mail mail]# cat trusted-users
# trusted-users – users that can send mail as others without a warning
# apache, mailman, majordomo, uucp, are good candidates
[root@mail mail]# cat virtusertable
# A domain-specific form of aliasing, allowing multiple virtual domains to be
# hosted on one machine.
# foo-info
# bar-info
# error:nouser 550 No such user here
# error:5.7.0:550 Address invalid
# then mail addressed to will be sent to the address foo-info,
# mail addressed to will be delivered to bar-info, and mail
# addressed to anyone at will be sent to, mail to
# will be rejected with the specified error message, and mail to
# will also have a RFC 1893 compliant error code 5.7.0.
# The username from the original address is passed as %1 allowing:
# Additionally, if the local part consists of “user+detail” then “detail” is
# passed as %2 and “+detail” is passed as %3 when a match against user+* is
# attempted, so entries like
# old+*
# gen+*
# +*
# %1%3
# Note: to preserve “+detail” for a default case (@domain) %1%3 must be used
# as RHS. There are two wildcards after “+”: “+” matches only a non-empty
# detail, “*” matches also empty details, e.g., matches#
# +* but not This can be used to ensure that the
# parameters %2 and %3 are not empty.
# All the host names on the left hand side (,, and
# must be in class {w} or class {VirtHost}. The latter can be defined by the
# macros VIRTUSER_DOMAIN or VIRTUSER_DOMAIN_FILE (analogously to
# VIRTUSER_DOMAIN_FILE is used, then the entries of class {VirtHost} are
# added to class {R}, i.e., relaying is allowed to (and from) those domains.
[root@mail mail]# cat virtusertable.db
root@mail]# telnet localhost 25
Trying ::1…
telnet: connect to address ::1: Connection refused
Connected to localhost.
Escape character is ‘^]’.
220 ESMTP Sendmail 8.14.4/8.14.4; Fri, 3 Jun 2016 18:27:50 -0700
ehlo Hello localhost [], pleased to meet you
250 HELP
250 2.1.0… Sender ok
250 2.1.5… Recipient ok
354 Enter mail, end with “.” on a line by itself
hai man how are u
250 2.0.0 u541Rofj008779 Message accepted for delivery

221 2.0.0 closing connection
Connection closed by foreign host.
root@mail]# vim /var/log/maillog

Jun 3 18:30:16 mail sendmail[8809]: u541Rofj008779:, delay=00:00:36, xdelay=00:00:01, mailer=relay, pri=120036, relay=a2nlvphout-v01.shr… [], dsn=2.0.0, stat=Sent (90PobKTMvRlXG mail accepted for delivery)

[root@mail ~]# cat >>firstfile

sendmail through file

[root@mail ~]# sendmail < /root/firstfile

[root@mail ~]# mail -s “Special Subject” < /root/mail/access

[root@mail ~]# mutt -s “Special Subject” < /root/mail/access



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s