setup sendmail
is my server an open relay
send a basic message
checking queued messages
deleting emails
to disable cron from sending email
checking logs
Checking email headers
useful links


To send and receive mail, the following need to be setup (and configured):

  • mta mail transfer agent - (sendmail/pop/imap) responsible for sending
  • mua mail user agent - mail clients i.e outlook,evolution,mail,mutt
  • mda mail delivery agent - local delivery agent (puts in mail box) proc mail

So what happens when you try to send an email?

  • it goes to local email server
  • message queued on the mail server
  • link established to destination (on port 25)
  • destination confirms ok and local sents it on
  • receipt of email confirmed
  • mda puts in mail spool for end receipant

without a catchall and if email address is wrong, destination email server will reject the mail
(although will retry) and bounce back message to the sender

if the destination mail server is down, the sending mail server will retry and eventually bounce back message to the sender if unsuccessful.

for details on setting up sendmail see

To receive mail you need to install a MTA (mail transfer agent) 2 of the most popular are postfix (installed by default with centos) and sendmail.

postfix is generally considered to be an improved version of sendmail. is the main sendmail configuration file. Is a macro that's easier to edit, which can be used to generate a new file.

setup sendmail

1) install sendmail,sendmail-cf and m4 and make sure postfix is turned off or uninstalled
2) edit the /etc/mail/ (note it is dnl (Lima) not dn1 (1 the number) and change

DAEMON_OPTIONS(`Port=smtp,Addr=, Name=MTA')dnl

dnl DAEMON_OPTIONS(`Port=smtp,Addr=, Name=MTA')dnl

3) m4 /etc/mail/ > /etc/mail/ (to build the config file)
4) service sendmail restart (restart the service
5) check sendmail is listening on port 25 (netstat -plant | grep LISTEN)
6) hostname >> /etc/mail/relay-domains
7) open your firewall iptables -A INPUT -p tcp -m tcp –dport=25 -j ACCEPT
8) if you want to receive email from multiple domains add the domain names to /etc/mail/local-host-names
9) to add catch all's add users to /etc/mail/virtusertable in the format @domain user_to_get_mail

you then need to setup the Dns mx records to point at your server

i was having a lot of issues setting this up initally,the best page i found was

is my server an open relay

run a test from somewhere such as

send a basic message

echo "test" | mail -s testsubject

checking queued messages

running mailq which is the same as sendmail -bp prints a summary of the mail messages queued for future delivery.

deleting emails

cd /var/spool/mqueue and delete all files if you want to get rid of all messages in the queue:

to disable cron from sending email

MAILTO="" to disable mail

Checking logs

cat /var/log/maillog


Checking email headers

a good site to check email headers


DomainKeys Identified Mail (DKIM) lets an organization take responsibility for a message that is in transit. The organization is a handler of the message, either as its originator or as an intermediary. Their reputation is the basis for evaluating whether to trust the message for further handling, such as delivery. Technically DKIM provides a method for validating a domain name identity that is associated with a message through cryptographic authentication.
more reading

Useful links

masquerade outgoing email address
sending emails using sendmail and having the sender set to something different from the user account