There once was a boy and he had a raspberry pi...... oh wait... I had a raspberry pi 3 laying around unused. So I decided to run all my websites and a mail server on it. That may sound crazy but the pi has more computing power than some of the servers we used in the late 90s to do the same thing. Mail and websites do not take a top of the line server to function. This is about the mail server portion of this. I blogged about the website setup with jails in another post.

Setting up a mail server is not as easy as it sounds. There are a lot of moving parts to get to work. The guy who wrote Sendmail, the original mail program, said email is not simple. He was pretty spot on. BUT, it is an easily attainable task to do. The steps are:

  1. install FreeBSD
  2. install Postfix
  3. configure your domain
  4. set up your dns records for your domain
  5. test receiving email
  6. configure outgoing mail
  7. send a test email out

I am not going to go through installing FreeBSD. I assume if you are looking to set up a mail server you are well past the point of me holding your hand to install FreeBSD. Besides, there are tons of excellent guides out there on installing FreeBSD. The second step is to install Postfix with the following command as root:

 
	# pkg install -y portmaster acme.sh postfix dovecot dovecot-pigeonhole \
  	mariadb106-server mariadb106-client nginx php82 php82-extensions \
  	rspamd redis roundcube-php82 postfixadmin-php82 clamav cmake-core \
  	devel/bison devel/gettext-tools devel/libtextstyle devel/gmake devel/m4 \
  	print/texinfo converters/p5-Text-Unidecode devel/p5-Locale-libintl \
  	misc/help2man devel/p5-Locale-gettext textproc/p5-Unicode-EastAsianWidth \
  	devel/ninja devel/pkgconf databases/db18 devel/autoconf \
  	devel/autoconf-switch devel/automake devel/re2c textproc/py-docutils \
  	devel/py-setuptools@py311 graphics/php82-gd graphics/jpeg-turbo \
  	devel/nasm graphics/png graphics/tiff archivers/libdeflate \
 	graphics/jbigkit graphics/webp graphics/giflib print/freetype2 \
  	archivers/brotli x11-fonts/fontconfig devel/gperf devel/meson \
  	devel/py-build@py311 devel/py-flit-core@py311 devel/py-installer@py311 \
  	devel/py-packaging@py311 devel/py-pyproject-hooks@py311 \
  	textproc/py-tomli@py311 devel/py-wheel@py311 textproc/php82-pspell \
 	textproc/aspell ports-mgmt/portconfig textproc/clucene devel/bsddialog
Once this is done I would suggest you go to www.purplehat.org and follow his guide to the LETTER. Do not do as I did and use certbot instead of the acme scripts as it will cause problems with cert permissions. Once you have done this you need to move on to configuring your dns. I bought my domains from GoDaddy.com, not an ad for them, that is just who I used years ago and have never moved them anywhere else. I use their domain servers for my domains. Go to the following link to get a simple howto on doing dns:
configuring-dns-for-email-a-quck-beginners-guide
Once you have completed all these steps log into your roundcube email and go to gmail or whereever else you have an email account and email yourself on your new account. That should send you an email. That is the easy part. Now on to sending email out from your domain.

If you are on a business account or an Internet provider that will allow you to send out email on port 25, your email is easy. If you are on a service like TDS that blocks email servers from sending email to minimize spam, you got more work to do. I am still hunting for the perfect solution for this. I am testing a couple of providers to find a free solution. More to come once I find a solution.