# avoiding problems and setting up mail



## dpalme (Mar 14, 2017)

Ok due to our own negligence, we have had to go to rebuild a server and its current to 10.3 at this time.  Base install at this point with only portmaster installed.

In the past we have always used sendmail but I recall there being some suggestions on a better approach that is easier to maintain, if any would like to share them with me - I've love to hear them.  Now is the time to reconsider sendmail for us.

I recall the last time we ended up with multiple copies of CF files and it all became a cluster....


----------



## SirDice (Mar 14, 2017)

People are quite happy with mail/opensmtpd as it's easier to configure. But other common alternatives are mail/exim and mail/postfix.


----------



## ShelLuser (Mar 14, 2017)

Also keep in mind that 'easier' is always in the eye of the beholder, it also heavily depends on your environment and your usage for mail usage. For example: are we talking about a mail relay (just a server which sends out mail for a couple of clients) or is this a full blown mail server which both sends and receives mail?

I use a couple of FreeBSD servers both professionally and in my personal environment and when it comes to e-mail then I rely on both Sendmail in the base system as well as mail/postfix. My LAN server services the mail for my LAN (doh) and because it only needs to collect mail and send it I'm relying on Sendmail because it does this job quite well. I basically only had to set up a smart host.

My main server on the other hand services mail for several domains, both incoming and outgoing, and there I prefer Postfix because it's a little more direct, easy to configure and also easy to expand on. For example, adding SPF support, Greylist support and even setting up a spamfilter (I prefer Spamassasin run as daemon) is relatively easy. Getting Postfix to use Postgrey (gray list daemon) basically took only one tweak:


```
smtpd_recipient_restrictions = check_policy_service inet:127.0.0.1:10023
```


----------



## dpalme (Mar 14, 2017)

I use an outside spam filter so that part is taken care of, I'm sending and receiving mail on the same box.  I've been using dovecot for imap.


----------



## usdmatt (Mar 14, 2017)

I used Postfix for a customer project a while ago as I needed a few specific features and Googling seemed to suggest they would be easier in Postfix. (Mainly due to there being much more readily available information / how-to's / etc for Postfix)

As of yesterday I've just finished moving all of our main mail systems to Postfix. Nothing wrong with Sendmail, and as it's in base you can get a basic mail server up and running in minutes, but I've found configuring just about everything is easier in Postfix. It runs great, logs are good, postfix-logwatch gives a nice overview of email stats, cool stuff like requiring TLS before smtp-auth is a simple yes/no option, the list goes on. I also find it much easier to tighten down access using the various _restrictions config options.


----------



## dpalme (Mar 14, 2017)

I'm assuming that I can still run dovecot with postfix correct?


----------



## SirDice (Mar 14, 2017)

One does not exclude the other. Postfix (or Exim) is used to receive and send email, dovecot is only used to _read_ email (IMAP/POP3).


```
root@mail:~ # ps -ax | egrep 'exim|dovecot'
89499  -  IWJ   0:00.00 dovecot/config
89501  -  IWJ   0:00.00 dovecot/auth
94932  -  IsJ   0:00.63 /usr/local/sbin/exim -bd -q30m
94990  -  IsJ   0:00.16 /usr/local/sbin/dovecot -c /usr/local/etc/dovecot/dovecot.conf
94991  -  IWJ   0:00.00 dovecot/anvil
94992  -  IWJ   0:00.00 dovecot/log
 7567  0  S+J   0:00.00 egrep postfix|dovecot
```


----------



## ShelLuser (Mar 14, 2017)

Not just that... You can even get Dovecot to share its authentication scheme with Postfix. In other words: you can set up Postfix so that it can authenticate users with the same username/password which they used with Dovecot to retrieve mail.


----------

