Mail Forwarding With Sendmail on FreeBSD

This is a guideline on how to enable sendmail as a mail forwarding service with Freebsd on a Digitalocean droplet or any other VPS.

Sendmail Configurations


Under this directory we need to copy or create access that “defines which hosts or IP addresses have access to the local mail server and what kind of access they have”.

% sudo cp access.sample access
% sudo vi access

We need to add the domain and kind of access it will have

# $FreeBSD: releng/11.0/etc/mail/access.sample 176353 2008-02-17 05:22:08Z gshapiro $
# Mail relay access control list. Default is to reject mail unless the
# destination is local, or listed in /etc/mail/local-host-names

We also need to copy or create the list of virtual users

% sudo cp virtusertable.sample virtusertable

then add the emails that you want to relay to, in my case I created a catch all email. This means that whatever email address is sent to will be forwarded to my personal email account.

# $FreeBSD: releng/11.0/etc/mail/virtusertable.sample 68266 2000-11-02 23:32:31Z dirk $
# Map one or all usernames at a source hostname to a specific (or the same)
# username at another target hostname. Remember to add the source hostname
# to /etc/mail/local-host-names so that sendmail will accept mail for the
# source hostname.

As stated in our /etc/mail/access config, “Mail relay access control list. Default is to reject mail unless the destination is local, or listed in /etc/mail/local-host-names” so we need to create the file and add our domain name.

% sudo vi local-host-names

then add the your domain

We need to recompile our configuration and restart the sendmail daemon

% make
% sudo service sendmail restart

Sendmail Service

After configuring sendmail, we need to make sure that we enable sendmail every time our server restart.


Add the following configuration

sendmail_submit_flags="-L sm-mta -bd -q30m"


Of course, we also need to allow incoming and outgoing connections to our smtp service,

% sudo vi /etc/ipfw.rules

then add

$cmd 00230 allow tcp from any to any 25 out via $pif setup keep-state

we need to restart our ipfw rule sets,

% sh /etc/ipfw.rules

We also need to check if the port is open,

% sockstat -4 -l

You should see something like

root sendmail 21199 3  tcp4  *:25          *:*



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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s