<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <id>tag:burkey.co,2005:/blog/feed</id>
  <link rel="alternate" type="text/html" href="https://burkey.co/blog"/>
  <link rel="self" type="application/atom+xml" href="https://burkey.co/blog/feed.xml"/>
  <title>burkey.co blog</title>
  <author>
    <name>Evan Burkey</name>
  </author>
  <updated>2026-08-13T00:45:36Z</updated>
  <entry>
    <id>tag:burkey.co,2005:Post/1</id>
    <published>2026-08-13T00:45:36Z</published>
    <updated>2026-08-13T00:48:41Z</updated>
    <link rel="alternate" type="text/html" href="https://burkey.co/blog/setting-up-mail-in-openbsd"/>
    <title>Setting up mail in OpenBSD</title>
    <summary>Being able to send email from your terminal is important if you plan to join the OpenBSD community. One of the first things you'll see after an install is a message saying that you've got mail, and inside will be a handy message about ho...</summary>
    <content type="html">&lt;p&gt;Being able to send email from your terminal is important if you plan to join the OpenBSD community. One of the first things you'll see after an install is a message saying that you've got mail, and inside will be a handy message about how to setup your machine. At the end you'll see the following:&lt;/p&gt;
&lt;pre style="background-color:#2b303b;"&gt;&lt;code&gt;&lt;span style="color:#c0c5ce;"&gt;If you wish to ensure that OpenBSD runs better on your machines, please do us a favor (after you have your mail system configured!) and type something like:
&lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt;
&lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt;# (dmesg; sysctl hw.sensors) | \
&lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt;   mail -s &amp;quot;Your System Description&amp;quot; dmesg@openbsd.org
&lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt;
&lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt;so that we can see what kinds of configurations people are running.
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But how do we get that pesky mail system configured? Reading the man pages for &lt;code&gt;smtpd(8)&lt;/code&gt; and &lt;code&gt;mail(1)&lt;/code&gt; will get you there, but here is a condensed version. Note that this only configures outgoing mail, which is all you really need. This allows you to send output from &lt;code&gt;dmesg(8)&lt;/code&gt;, terminal output when asking about problems, or even send patches you've built straight through email!&lt;/p&gt;
&lt;p&gt;First, get your smtp credentials from your email provider. Once you have that, use &lt;code&gt;su&lt;/code&gt; to become the &lt;code&gt;root&lt;/code&gt; user. Create the file &lt;code&gt;/etc/mail/secrets&lt;/code&gt; and add the following:&lt;/p&gt;
&lt;pre style="background-color:#2b303b;"&gt;&lt;code&gt;&lt;span style="color:#c0c5ce;"&gt;identifier my@email.com:MySecretKey
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Change &lt;code&gt;identifier&lt;/code&gt; to whatever you want, this will be your secret's identifier name. Adjust the email address and your smtp auth key in place of &lt;code&gt;MySecretKey&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;This secrets file needs specific permissions, so let's do a little &lt;code&gt;chown/chmod&lt;/code&gt; magic&lt;/p&gt;
&lt;pre lang="sh" style="background-color:#2b303b;"&gt;&lt;code&gt;&lt;span style="color:#8fa1b3;"&gt;$&lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt; chown root:_smtpd /etc/mail/secrets
&lt;/span&gt;&lt;span style="color:#8fa1b3;"&gt;$&lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt; chmod 640 /etc/mail/secrets
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next, configure &lt;code&gt;smtpd(8)&lt;/code&gt; for outbound mail. You'll start by modifying &lt;code&gt;/etc/mail/smtpd.conf&lt;/code&gt; to look something similar to the following:&lt;/p&gt;
&lt;pre style="background-color:#2b303b;"&gt;&lt;code&gt;&lt;span style="color:#c0c5ce;"&gt;table aliases file:/etc/mail/aliases
&lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt;table secrets file:/etc/mail/secrets
&lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt;
&lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt;listen on socket
&lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt;listen on lo0
&lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt;
&lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt;action &amp;quot;local_mail&amp;quot; mbox alias &amp;lt;aliases&amp;gt;
&lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt;action &amp;quot;relay&amp;quot; relay host smtp+tls://identifier@smtp.email.com:587 auth &amp;lt;secrets&amp;gt;
&lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt;
&lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt;match from local for local action &amp;quot;local_mail&amp;quot;
&lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt;match from local for any action &amp;quot;relay&amp;quot;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The important parts here are adding the line &lt;code&gt;table secrets file:/etc/mail/secrets&lt;/code&gt; at the top to import our secrets table and replacing the pre-defined outbound configuration with a relay to our email provider's smtp server. The smtp address will need to match the identifier name you set in &lt;code&gt;/etc/mail/secrets&lt;/code&gt;, so if your secrets file said something like &lt;code&gt;iambob bob@gmail.com:12345&lt;/code&gt;, then your smtp address would look something like &lt;code&gt;smtp+tls://iambob@smtp.gmail.com:587 auth &amp;lt;secrets&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The standard port for smtp is &lt;code&gt;587&lt;/code&gt;, so odds are your email provider is using that. Doublecheck to be safe.&lt;/p&gt;
&lt;p&gt;Now you can check that your config is correct and get things started up&lt;/p&gt;
&lt;pre lang="sh" style="background-color:#2b303b;"&gt;&lt;code&gt;&lt;span style="color:#65737e;"&gt;# Checks your config for errors
&lt;/span&gt;&lt;span style="color:#8fa1b3;"&gt;$&lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt; smtpd&lt;/span&gt;&lt;span style="color:#bf616a;"&gt; -n
&lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt;
&lt;/span&gt;&lt;span style="color:#65737e;"&gt;# Restart smtpd
&lt;/span&gt;&lt;span style="color:#8fa1b3;"&gt;$&lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt; rcctl restart smtpd
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;One last step before we're done: A quick &lt;code&gt;Ctrl+D&lt;/code&gt; to drop back to your regular user account, and open up &lt;code&gt;~/.mailrc&lt;/code&gt; using your text editor of choice. Add the following line at the bottom of the file. This will set the &lt;code&gt;FROM&lt;/code&gt; header of your emails properly, without it &lt;code&gt;mail(1)&lt;/code&gt; will put your username and hostname as the&lt;br /&gt;
sender, which will break smtp authentication.&lt;/p&gt;
&lt;pre lang="sh" style="background-color:#2b303b;"&gt;&lt;code&gt;&lt;span style="color:#96b5b4;"&gt;set&lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt; from=&amp;quot;&lt;/span&gt;&lt;span style="color:#a3be8c;"&gt;my@email.com&lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt;&amp;quot;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You should be good to go at this point. Test it out by sending yourself a quick test email.&lt;/p&gt;
&lt;pre lang="sh" style="background-color:#2b303b;"&gt;&lt;code&gt;&lt;span style="color:#96b5b4;"&gt;echo&lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt; foo | &lt;/span&gt;&lt;span style="color:#8fa1b3;"&gt;mail&lt;/span&gt;&lt;span style="color:#bf616a;"&gt; -s&lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt; bar my@email.com
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Even better, send your system info to the OpenBSD developer team! Be sure to set the email's subject line to some information about your computer. Here's the invocation I used on my latest workstation build&lt;/p&gt;
&lt;pre lang="sh" style="background-color:#2b303b;"&gt;&lt;code&gt;&lt;span style="color:#c0c5ce;"&gt;(&lt;/span&gt;&lt;span style="color:#8fa1b3;"&gt;dmesg&lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt;; &lt;/span&gt;&lt;span style="color:#8fa1b3;"&gt;sysctl&lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt; hw.sensors) | &lt;/span&gt;&lt;span style="color:#8fa1b3;"&gt;mail&lt;/span&gt;&lt;span style="color:#bf616a;"&gt; -s &lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#a3be8c;"&gt;Gigabyte B650M K, Ryzen 7 7700X, RX 6750XT. Had to disable Re-Size BAR Support for amdgpu to init&lt;/span&gt;&lt;span style="color:#c0c5ce;"&gt;&amp;quot; dmesg@openbsd.org
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you run into any issues, look at &lt;code&gt;/var/log/maillog&lt;/code&gt;. The entire flow of your mail getting sent out will be logged there, and you should be able to discern what is wrong.&lt;/p&gt;
</content>
  </entry>
</feed>
