Difference between revisions of "Sendmail"

From ArchWiki
Jump to: navigation, search
(sendmail.cf)
Line 22: Line 22:
 
FEATURE(use_cw_file)
 
FEATURE(use_cw_file)
 
dnl FEATURE(`relay_entire_domain')dnl
 
dnl FEATURE(`relay_entire_domain')dnl
 +
FEATURE(`access_db')dnl
 
FEATURE(`virtusertable', `hash /etc/mail/virtusertable.db')dnl
 
FEATURE(`virtusertable', `hash /etc/mail/virtusertable.db')dnl
 
OSTYPE(linux)dnl
 
OSTYPE(linux)dnl
Line 29: Line 30:
 
* Then process it with
 
* Then process it with
 
  m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
 
  m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
 +
 
===local-host-names===
 
===local-host-names===
 
* Create the file {{ic|/etc/mail/local-host-names}} and put there your domains:
 
* Create the file {{ic|/etc/mail/local-host-names}} and put there your domains:

Revision as of 21:41, 24 August 2012

Sendmail is the classical SMTP server from the unix world. It was originally coded long time ago, when the internet was a safer place, and back then, security didn't matter as much as does today. Therefore it used to have several security bugs and it got some bad reputation for that. But those bugs are long fixed and a recent sendmail version is as safe as any other SMTP server. If your top priority is security, you should probably use netqmail, however.

The goal of this article is to setup Sendmail for local users accounts, without using mysql or other database, and allowing also the creation of mail-only accounts.

This article only explains the required steps configuring Sendmail; after that, you probably want to add IMAP and POP3 access, so you could follow the Dovecot article.

Installation

Install the package sendmailAUR from the AUR, and the package procmail from the official repositories.

DNS Records

You should have a domain, and edit your MX records to point your server. Remember some servers have problems with MX records pointing to CNAMEs, so your MX should point to an A record instead.

Adding users

  • By default, all the local users can have an email address like username@your-domain.com. But if you want to add mail-only accounts, that is, users who can get email, but can't have shell access or login on X, you can add them like this:
useradd -m -s /sbin/nologin joenobody
  • Assign a password:
passwd joenobody

Configuration

sendmail.cf

  • Create the file /etc/mail/sendmail.mc with the following content:
include(`/usr/share/sendmail-cf/m4/cf.m4')
FEATURE(use_cw_file)
dnl FEATURE(`relay_entire_domain')dnl
FEATURE(`access_db')dnl
FEATURE(`virtusertable', `hash /etc/mail/virtusertable.db')dnl
OSTYPE(linux)dnl
MAILER(local)dnl
MAILER(smtp)dnl
  • Then process it with
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

local-host-names

  • Create the file /etc/mail/local-host-names and put there your domains:
localhost
your-domain.com
mail.your-domain.com
localhost.localdomain

access.db

  • Create the file /etc/mail/access and put there the base addresses where you want to be able to relay mail. Lets supose you have a vpn on 10.5.0.0/24, and you want to relay mails from any ip in that range:
10.5.0 RELAY
127.0.0 RELAY
  • Then process it with
makemap hash /etc/mail/access.db < /etc/mail/access

aliases.db

  • Edit the file /etc/mail/aliases and uncomment the line #root: human being here and change it to be like this:
root:         your-username
  • You can add aliases for your usernames there, like:
coolguy:      your-username
somedude:     your-username
  • Then process it with
newaliases

virtusertable.db

  • Create the file /etc/mail/virtusertable and put there aliases that includes domains (useful if your server is hosting several domains)
your-username@your-domain.com         your-username
joe@my-other.tk                       joenobody
  • To forward all mail addressed to any user in the "my-other.tk" domain to "your-username@your-domain.com":
@my-other.tk        your-username@your-domain.com
  • Then process it with
makemap hash /etc/mail/virtusertable.db < /etc/mail/virtusertable

Start the server

/etc/rc.d/sendmail start