Posts: 1
Joined: Wed Jan 09, 2019 11:19 am

Setting up "basic" mail

Wed Jan 09, 2019 11:28 am

Hi. I am trying to setup dovecot. As part of the basic directions it suggests sending an email to a user on the PI - to see how the already running mail server delivers mail. However, I do not seem to be able to use the example: 'mail -s "Dovecot test" $User' as I cannot find the program /usr/bin/mail aka command-line mail aka bellmail.

It seems 'simple' is too hard and/or I am not smart enough to find a package with it using apt-file and apt-cache.

Thanks (and best wishes for 2019)

p.s. - as most google hits come up with threads from 2013, 2014 - and one from 2017 - I am starting a new one hoping it will, ultimately, be more relevant to the current software availability and practices.

Posts: 488
Joined: Thu Oct 23, 2014 12:14 am
Location: Texas
Contact: Website

Re: Setting up "basic" mail

Wed Jan 09, 2019 3:59 pm

mail is part of the mailutils package (and I think some other). It delivers mail to a user or to a mail transfer agent.

You need to install the rest of the mail system however, something to collect and deliver the mail. I really like sendmail for that but you will get plenty of other suggestions. I've run dovecot and sendmail for years on linux systems and for a bit on Pis. The "mail" program is part of the mailutils package and can be installed with apt. If you just attempt to install mailutils, apt will also install another mail program at the same time. I can't remember which one at the moment but if you want sendmail install it first or concurrently with mailutils. I can help you configure your sendmail/dovecot and I'm sure there are folks that can help you with postfix, exim or one of the other MTAs.

User avatar
Posts: 15931
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Setting up "basic" mail

Wed Jan 09, 2019 4:03 pm

A default Debian installation includes basic local mail delivery, but Raspbian does not, probably because it's not needed for the main target audience.

Posts: 393
Joined: Sat Oct 14, 2017 9:57 pm

Re: Setting up "basic" mail

Sun Jan 13, 2019 3:39 pm


If you only want to send emails and do not wish to receive them, then I'd suggest ssmtp package (simple smtp, and indeed it's simple to set up). That will provide you /usr/bin/sendmail, and it is compatible with other MTAs (sendmail, exim, qmail etc.). The only downside is, you won't store mails locally, therefore you'll need an smtp relaying hub (should be provided by your ISP, or you can use the recipient mx server directly).
For example, if you want to send those mails to a gmail account, then you can set up ssmtp to directly send to gmail-smtp-in.l.google.com (to figure out the mx server for the address "abc @ def.ltd", use "host -t MX def.ltd", or ask their tech support :-) In case of google, smtp.gmail.com should work too).

https://raspberrypi.stackexchange.com/q ... end-emails
https://howtovmlinux.com/articles/rasbe ... rrypi.html


Posts: 6
Joined: Sun Apr 07, 2019 9:57 am
Contact: Website Twitter

Re: Setting up "basic" mail

Tue Jul 30, 2019 7:15 pm

Hi. A basic (but complet) private mail solution should consider at least the following features:
  • MTA (Mail Transfer Agent): is the feature that allows you transferring mail to/from external world
  • MDA (Mail Delivery Agent): is what allows you to deliver mails from server where they are stored to your client. This service exposes the well known IMAP / POP3 protocols
  • (optional): a web interface to access your mails also without having a client installed
Mail can be stored on a database (usually *SQL like) or directly as files on file system. A working, very simple and cheap solution can be reached (between others) with the following Open Source software:
  • MTA: Postfix
  • MDA: Dovecot
  • Web Interface: Squirrelmail
Ubuntu Docs has guide for these software, but a few moths ago (Oct 2018) I tested these software on... a Raspberry Pi Zero W! What I realized is that some small corrections are needed to Ubuntu procedure to setup them on Raspbian (Stretch Lite).
Even if it is working only in case of a few users, it worked!
If you are interested, you can find the complete guide at https://peppe8o.com/2018/10/mailserver- ... irrelmail/. In this case you don't need any external service (SMTP is part of Postfix), but you must be aware that mail sent can go in Spam folder for internet mail services which have filters based on IP addresses filtering.

User avatar
Posts: 15931
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Setting up "basic" mail

Tue Jul 30, 2019 7:51 pm

The "spam" thing is one reason I don't run my external mailserver on a Pi. It's not a problem with the Pi, which is perfectly capable of running it, but because the IP address will resolve to my ISP connection, not my mailserver on a reverse lookup.

Instead I use a cheap VPS running Debian with a Docker container for the email server. Postfix and Dovecot. Email servers are blocked by default from the VPS supplier, but a quick email to support explaining what I was going to use it for and that I would take precautions to prevent it being a mail relay (very important!) cleared that up quickly (within about 45 minutes on a Sunday morning, when support is supposed to be 4-8 hours on working days only!). I have SSL set up and use a MySQL/MariaDB database for the email user details. The database is actually held on a Pi at home, then replicated to a slave database on the server via my VPN. I also have a tweak to the rules where any email sent to [email protected]$mydomain gets through to me and is processed by filters on my mail client. This is handy for signing up to things as I can just make up part of the email address and it will work without me having to change anything. :)

Return to “Networking and servers”