In the following article we will guide you through the steps of installing and configuring a simple mail server using Sendmail and Dovecot on a Fedora 20 Linux VPS.
What is Sendmail?
It is a general purpose email routing facility that supports many kinds of mail-transfer and delivery methods, including the Simple Mail Transfer Protocol (SMTP) used for email transport over the Internet.
What is Dovecot?
Dovecot is an open source IMAP and POP3 server for Linux/UNIX-like systems. It can work with standard mbox, Maildir, and its own native high-performance dbox formats. It is fully compatible with UW IMAP and Courier IMAP servers’ implementation of them, as well as mail clients accessing the mailboxes directly. Dovecot also includes a Mail delivery agent (called Local delivery agent LDA) with optional Sieve filtering support.
1. UPDATE THE SYSTEM
Before proceeding any further, make sure you are in a screen session and check if your Fedora 20 Linux VPS is fully up-to-date by running:
## screen -U -S sendmail-screen ## yum update
2. INSTALL AND CONFIGURE SENDMAIL
Install Sendmail MTA using the following command
## yum install sendmail sendmail-cf sendmail-doc cyrus-sasl-{lib,plain}
change to /etc/mail
directory
## cd /etc/mail
edit sendmail’s sendmail.mc
configuration file and add/change the following
## cp sendmail.mc{,.orig} ## vim sendmail.mc
define(`PROCMAIL_MAILER_PATH', `/usr/bin/procmail')dnl define(`confAUTH_OPTIONS', `A')dnl TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl FEATURE(local_procmail)dnl DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA')dnl DAEMON_OPTIONS(`Port=submission, Name=MSA, M=Ea')dnl MAILER(procmail)dnl
save and close the file and make
sendmail’s configuration by running the following commands
## cd /etc/mail ## make all
restart sendmail and add it to your linux vps start-up using systemctl
## systemctl restart sendmail saslauthd ## systemctl enable sendmail saslauthd
for your convenience, below is the complete sendmail.mc
configuration file:
divert(-1)dnl include(`/usr/share/sendmail-cf/m4/cf.m4')dnl VERSIONID(`setup for linux')dnl OSTYPE(`linux')dnl define(`confDEF_USER_ID', ``8:12'')dnl define(`confTO_CONNECT', `1m')dnl define(`confTRY_NULL_MX_LIST', `True')dnl define(`confDONT_PROBE_INTERFACES', `True')dnl define(`PROCMAIL_MAILER_PATH', `/usr/bin/procmail')dnl define(`ALIAS_FILE', `/etc/aliases')dnl define(`STATUS_FILE', `/var/log/mail/statistics')dnl define(`UUCP_MAILER_MAX', `2000000')dnl define(`confUSERDB_SPEC', `/etc/mail/userdb.db')dnl define(`confPRIVACY_FLAGS', `authwarnings,novrfy,noexpn,restrictqrun')dnl define(`confAUTH_OPTIONS', `A')dnl TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl define(`confTO_IDENT', `0')dnl FEATURE(`no_default_msa', `dnl')dnl FEATURE(`smrsh', `/usr/sbin/smrsh')dnl FEATURE(`mailertable', `hash -o /etc/mail/mailertable.db')dnl FEATURE(`virtusertable', `hash -o /etc/mail/virtusertable.db')dnl FEATURE(redirect)dnl FEATURE(always_add_domain)dnl FEATURE(use_cw_file)dnl FEATURE(use_ct_file)dnl FEATURE(local_procmail)dnl FEATURE(`access_db', `hash -T<TMPF> -o /etc/mail/access.db')dnl FEATURE(`blacklist_recipients')dnl EXPOSED_USER(`root')dnl DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA')dnl DAEMON_OPTIONS(`Port=submission, Name=MSA, M=Ea')dnl FEATURE(`accept_unresolvable_domains')dnl LOCAL_DOMAIN(`localhost.localdomain')dnl MAILER(smtp)dnl MAILER(procmail)dnl
3. INSTALL AND CONFIGURE DOVECOT
Install dovecot
using the command below
## yum install dovecot
change to dovecot’s directory in /etc/dovecot
## cd /etc/dovecot
and edit the following
## vim conf.d/10-mail.conf ... mail_location = maildir:~/Maildir
## vim conf.d/10-ssl.conf ... ssl = yes
## vim conf.d/10-auth.conf ... disable_plaintext_auth = no auth_mechanisms = plain login
next, edit dovecot’s main configuration file and add/edit the following
## vim dovecot.conf ... protocols = imap pop3 lmtp listen = *
start Dovecot and add it to your Fedora system’s start-up using
## systemctl restart dovecot ## systemctl enable dovecot
4. SET-UP PROCMAIL
Add the following to /etc/procmailrc
## vim /etc/procmailrc DEFAULT=$HOME/Maildir/
5. CREATE A NEW USER
Create new user using the following command
## useradd -m test
set password for the newly created info
account
## passwd test
add your mydomain.com
domain name to /etc/mail/local-host-names
## echo mydomain.com >> /etc/mail/local-host-names
and create an alias for the newly created email account, by adding the following to /etc/mail/virtusertable
## vim /etc/mail/virtusertable test@mydomain.com test sales@mydomain.com test
rebuild sendmail’s configuration by running the following commands
## cd /etc/mail ## make all ## systemctl restart sendmail
Of course, if you are one of our Linux VPS Hosting customers, you don’t have to do any of this, simply ask our admins, sit back and relax. Our admins will set this up for you immediately.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.
how setup a client with this configuracion?
You can setup your email client using the following settings:
Incoming Server: yourdomain.com
Incoming Protocol: IMAP
Incoming Port: 143
Outgoing Server: yourdomain.com
Outgoing Port: 25 or 587
with pop?
Yes, you can also use POP3 if you like.
how can i use that on sendblaster
More information on this you can find here.
Great article! Out of many we reviewed, this was the only one that worked for us.
Thanks!!!
I have Centos 7 and Procmail but not found this path
/etc/procmailrc.
what wrong?
You may create /etc/procmailrc file if it does not exist.
i had do that step by step, it send mail successful, but the mail cannot recive. any idea?
You can check the log files for errors. Thanks.
I have seen the same problem with this article.
Mail can be sent out with Sendmail, but mail is not showing up in user’s INBOX.
The maillog shows mail coming into the server, but it is being stored in a different location from where dovecot is looking for the email. Just setting the mail_location in dovecot as shown above is not the complete solution to this problem. If anyone has any suggestions, please share them. It appears Sendmail is storing emails in a different place from where Dovecot is looking for them.
I had to read this three times because I wanted to be sure on some of your points. I agree on almost everything here, and I am impressed with how well you wrote this article.
After looking all over the Internet for weeks at dozens of articles, I finally found one that works! Thank you guys very much!
One last thing, how do you get aliases to work?
Run newaliases command after changing the /etc/aliases file
after doing all the steps . i used telnet to test the system but i can getting No route found to host when i connect to port 110.
can you help?
How to check my mail configuration it’s working or not.
please give suggestion.
Please follow the tutorial instructions closely, especially the ‘CREATE A NEW USER’ section.
In short, you need to create a new user account, add your domain name to the ‘/etc/mail/local-host-names’ file, add ‘username@mydomain.com username’ to the ‘/etc/mail/virtusertable’ file , rebuild Sendmail’s configuration and restart Sendmail for the changes to take effect.
can this one work on a centos 6??
This tutorial is written and tested on a Fedora 20 VPS, but you can also try it on your CentOS 6 VPS.
ihave sendmail installed to fedora workstation not encrypted.Also i ntalled dovecot.
Ihave accounts : root fedora info afotiadou
Send receive from the fedora account works ok
I cant send or receive from accounts info root afotiadou
Help please.
First open a terminal window and type in tail -f /var/log/maillog and in another terminal window send a test e-mail to your e-mail account using echo “Test” | mail -s “Test” test@email.com then copy paste the output to us from the first terminal window.