Hullo world! For this post, we'll setup a quickie mail server. The idea here as with most other post, is to setup basic mail server to get you going, so you can spend your time fiddling with advance setting rather than groping your way on how setup mail server. Note that a critical component (that we won't tackle here) is a working DNS setup. It's crucial that you have an MX record pointing to working domain. If you haven't setup one up yet, check this quickie post. Otherwise, you need to set one up before proceeding.
Also, we'll use the "exampledns.com" previously setup as example domain. Hostname of the machine that you working on is "node1.exampledns.com". You also have local user 'gene' and 'user1'
For this series of post, we'll setup the following:
- Sendmail
- Dovecot
- SquirrelMail
- SpamAssassin
Basic Setup of Sendmail:
Step 1: Log in as root and install all the necessary packages:
# yum -y install M4 sendmail sendmail-cf sendmail-doc dovecot
Step 2: By default, Sendmail only accept connection from loopback device or 127.0.0.1, you need to enable Sendmail to accept connection to your other network interface. To do this, edit /etc/mail/sendmail.mc (make sure to create a backup first), look for the following entry,
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
And change it to,
dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
Step 3: Edit /etc/mail/local-host-names and list all hostnames in your network that is acting as MX recipient. In my case, I have the following:
exampledns.com
node1.exampledns.com
mail.exampledns.com
Note that you might have a different settings here.
Step 4: Update the sendmail.cf config file and restart Sendmail service and then send test mail.
# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
# service sendmail restart
# su - gene
[gene]$ echo | mail -s "test email from gene" user1@exampledns.com
[gene]$ su - user1
[user1]$ mail
Note: From local user gene, you should be able to see emails from root account.
Step 5a: By default, Sendmail doesn't use 'write' your domain name to outgoing email. The above email from gene would show on user1 as coming from gene@localhost.localdomain. To write the '@exampledns.com' domain to outgoing emails, edit /etc/mail/sendmail.mc and find the following settings:
dnl MASQUERADE_AS(`domain-name.com')dnl
dnl FEATURE(masquerade_entire_domain)dnl
dnl FEATURE(masquerade_envelope)dnl
Step 5b: Remove the prefix dnl, so you have something similar below. And specify the domain name you wish that your outgoing emails will use. Edit /etc/mail/sendmail.mc and add the following settings:
MASQUERADE_AS(`exampledns.com')dnl
FEATURE(masquerade_entire_domain)dnl
FEATURE(masquerade_envelope)dnl
Step 5c: Update sendmail config file and restart your Sendmail service
# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
Step 6b: Restart Sendmail:
# service sendmail restart
or
# newaliases
Step 9: Setup your imap server using Dovecot. Log in as root, edit /etc/dovecot.conf and add the following:
# cp /etc/dovecot.conf /etc/dovecot.conf-original
# vi /etc/dovecot.conf
protocols = imap pop3
# service dovecot start
Note: In future post, we'll setup a more secure IMAP server using certificates.
Step 10: Test your imap server using your email client (ie. kmail, thunderbird, evolution, etc)
Watch out for the continuation of this Quickie Mail Server Setup Tutorial using Sendmail, Dovecot, SquirrelMail, SpamAssassin on Fedora 8.
# su - gene
[gene]$ echo | mail -s "test email from gene" user1@exampledns.com
[gene]$ su - user1
[user1]$ mail
Note: From local user gene, you should be able to see emails from root account.
Step 5a: By default, Sendmail doesn't use 'write' your domain name to outgoing email. The above email from gene would show on user1 as coming from gene@localhost.localdomain. To write the '@exampledns.com' domain to outgoing emails, edit /etc/mail/sendmail.mc and find the following settings:
dnl MASQUERADE_AS(`domain-name.com')dnl
dnl FEATURE(masquerade_entire_domain)dnl
dnl FEATURE(masquerade_envelope)dnl
Step 5b: Remove the prefix dnl, so you have something similar below. And specify the domain name you wish that your outgoing emails will use. Edit /etc/mail/sendmail.mc and add the following settings:
MASQUERADE_AS(`exampledns.com')dnl
FEATURE(masquerade_entire_domain)dnl
FEATURE(masquerade_envelope)dnl
Step 5c: Update sendmail config file and restart your Sendmail service
# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
# service sendmail restart
Your outgoing mail should now look like gene@exampledns.com.
Miscellaneous Setup of Sendmail:
Step 6a: Set-up your aliases. For example, all inquiries sent to inquiry@exampledns.com will be forwarded to gene@exampledns.com. Edit /etc/aliases file and add the following entry at the bottom of the file:
inquiry: gene@exampledns.com
Your outgoing mail should now look like gene@exampledns.com.
Miscellaneous Setup of Sendmail:
Step 6a: Set-up your aliases. For example, all inquiries sent to inquiry@exampledns.com will be forwarded to gene@exampledns.com. Edit /etc/aliases file and add the following entry at the bottom of the file:
inquiry: gene@exampledns.com
Note: To refer to a filename for a list of user that will resolve to an alias (ie. mailing list setup), use the following format:
alias: :include:/path/to/file
So you could have something like:
company-announcement: :include:/etc/mail/staff-list
Step 6b: Restart Sendmail:
# service sendmail restart
or
# newaliases
Step 7a: To accept or reject mails coming from selected users or domain, edit the /etc/mail/access file and add something along the lines of:
spammer@spam.com REJECT
192.168.3.200 DISCARD
sendmail.com REJECT
(RELAY reject the sender or recipient with general purpose error message. DISCARD drop the mail without any error message or notification to the sender or recipient.)
Step 7b: Rebuild the access file database and restart the Sendmail program:
# makemap hash /etc/mail/access.db < /etc/mail/access
# service sendmail restart
Step 8a: Set a cap the size of email attachment. Add the following entries to sendmail.mc
define(`confMAX_MESSAGE_SIZE', `size-in-bytes')dnl
Step 8b: Update sendmail config file and restart your Sendmail service
# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
# service sendmail restart
Step 9: Setup your imap server using Dovecot. Log in as root, edit /etc/dovecot.conf and add the following:
# cp /etc/dovecot.conf /etc/dovecot.conf-original
# vi /etc/dovecot.conf
protocols = imap pop3
# service dovecot start
Note: In future post, we'll setup a more secure IMAP server using certificates.
Step 10: Test your imap server using your email client (ie. kmail, thunderbird, evolution, etc)
Watch out for the continuation of this Quickie Mail Server Setup Tutorial using Sendmail, Dovecot, SquirrelMail, SpamAssassin on Fedora 8.

No comments:
Post a Comment