Håkon Robbestad Gylterud

newmail is a simple script to generate random e-mail aliases from the command line for OpenSMTP on OpenBSD. I wrote this to avoid having to give out my real e-mail address to every place which requires registration.

whichmail lets you look up which e-mail you generated for a specific site/purpose.


To get a new e-mail address, you simply run newmail, with an optional argument identifying the site you associate with this address:$ newmail

And if you later forgot which one you had generated:$ whichmail

How does it work?

After running newmail, the following lines have been added to /etc/mail/aliases:

# f5cb7a763186dea37d3f98f7ce9bae6a9449587892acd69f89f88bcae71e694f
pemovrypur:     user



Download and copy the above scripts to

Edit the configuration variables at the top of the script. Remember to read through the source files to understand what they do. Then consider applying a few conveniences to your system configuration.

The following line in /etc/doas.conf enables users3 to run it:

permit nopass :users as root cmd newmail

For ease of use, I also added the following to /etc/skel/.profile and current users $HOME/.profile:

alias newmail='doas newmail'


The scripts are written in rc (the shell of Plan9port). You can easily port them to any other shell your self. The newmail script itself is roughly ten lines.

  1. pkg_add apg

  2. pkg_add plan9port

  3. change the group to what-ever fits your system

Expecting a comment section? Feel free to e-mail me your comments, or otherwise contact me to discuss the content of this site. See my contact info. You can also write your opinion on your own website, and link back here! ☺