I'm looking to send emails to myself from various scripts on my Linux (Debian 10) system. My thought was to install just Dovecot, and not an MTA like Postfix, to avoid the complexity of configuring the MTA. All I want to do is drop myself the odd email from a script, and then connect to my mail server with Thunderbird and pull those emails.

I used to run my own email server, however, and the way I sent scripts on there was to use /usr/sbin/sendmail. This binary seems to have been supplied by Postfix, because it isn't there with just a Dovecot install.

Assuming I have already set up Dovecot to successfully allow retrieval of email from local user mailboxes via eg. POP3, what's the simplest way (least configuration, basically) for me to send email to those local mailboxes from a unix script? I'd like to avoid installing a full-on MTA, or ideally, anything else at all. I'd like some sort of equivalent to:

/usr/sbin/sendmail "[email protected]" <<EOF_emailContent
(email here)
  • What is your OS? The setup of an MTA for local delivery only should not be too difficult.
    – Bodo
    Commented Jan 20, 2022 at 12:10
  • Linux (Debian 10).
    – Jez
    Commented Jan 20, 2022 at 13:29
  • I suggest to install an MTA, e.g. exim4. IIRC it has a menu-based configuration where it should be easy to select a configuration for local delivery.
    – Bodo
    Commented Jan 20, 2022 at 13:57
  • See this answer to Minimal MTA that delivers mail locally for a script solution.
    – not2savvy
    Commented Nov 19, 2023 at 16:16

2 Answers 2


The basic problem is that without an MTA, these mailboxes have no email address. They are nothing but some files on disk. Dovecot doesn't need to understand email addresses.

The usual arrangement between an MTA (like postfix) and Dovecot is that both the MTA and Dovecot are configured to expect the same layout of either mbox files or maildir directories. But the mapping is very different for the MTA vs Dovecot.

  • Dovecot understands which users read / write which mailboxes
  • The MTA understands which email addresses get routed to which mail boxes.

You might assume that an email sent to [email protected] would go to user bob; that only happens because the MTA knows to route [email protected] into bob's mailbox /home/bob/.mail. Then when bob logs in via IMAP or POP3, Dovecot know that bob's mailbox is /home/bob/.mail.

...But the MTA might also route emails for [email protected] to bob's mailbox too. It may even route [email protected] into /home/mary/.mail when bob quits the company and his successor receives his email. It's entirely the job of the MTA to decide.

So without an MTA of some sort, you cannot route email into inboxes.

There are simpler MTAs. Postfix is rather awkward to configure and nobody wants the risk of accidentally misconfiguring an MTA and letting spammers abuse it.

I'll draw your attention to another question here on U&L which is similar (not duplicate?). Minimal MTA that delivers mail locally (for cron)?

If you are willing to roll your own, then the formats of both maildir and mbox are pretty simple. Though maildir is much safer to work with. Delivering to maildir is as simple as writing to the tmp directory and then moving (renaming) it into the new directory.

Of course these have to be well formatted emails with appropriate headers such as From: To: Subject: Date:. Examples can be found in RFC 5322

  • I don't really need to route email addresses though. As I said I'm just sending some emails to myself locally so my script could just specify "send to bob's mailbox".
    – Jez
    Commented Jan 20, 2022 at 16:44
  • @Jez yes that's why I linked that answer. The point of this answer is to highlight that this functionality is outside of Dovecot's remit and any MTA (even femto) is build on the concept of sending to an email address. If you are using maildir (not mbox) then delivering mail to the mailbox is as trivial as writing the email as a file into the new directory. Remember to add email headers such as From:, To: and Subject: etc. Commented Jan 20, 2022 at 16:49

Dovecot comes with a special local delivery agent dovecot-lda, so you can send mail from a script to a local dovecot mailbox directly, without any MTA like sendmail or postfix:

/usr/local/libexec/dovecot-lda -d user_name <<EOF_emailContent
(email here)

user_name is any valid dovecot user, either system or virtual, depending on how you've configured dovecot. man dovecot-lda for more options.

P.S. Location of dovecot-lda executable may vary. On my FreeBSD box it's at /usr/local/libexec/dovecot/dovecot-lda.

P.S.2. Dovecot also provides LMTP (local mail transfer protocol) unix socket. So if your script is designed to send emails via SMTP (that is, you've implemented SMTP communication in your script), then you can somehow redirect that communication from local TCP port 25 to dovecot local unix domain socket /var/run/dovecot/lmtp and enjoy.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .