temp-email
NOTE WORK IN-PROGRESS, NOT YET READY FOR USE
Do you often give out temporary email addresses to online services or in-person? Is it annoying to have to set them up manually each time? Want to have them auto-generated based on a regex pattern?
temp-email provides a Postfix TCP map that dynamically generates temporary, expiring valid email addresses, so that you can pick one out of the air without having to configure it in advance, provided it matches a pattern. These temporary addresses can expire after a certain time, a certain number of uses, or both. After this temp-email will pretend that they are unknown, causing Postfix to reject any email sent to them. Finally, any of the expired addresses can be "aged out" and forgotten about after a long enough period of time so they will eventually work again.
Installation
TODO Write installation instructions here
Usage
Configuration
If run as root (not recommended), temp-email reads the configuration file /etc/temp-emailrc
. If run as a user it reads ~/.temp-emailrc. The configuration files consists of single lines that are either configuration directives or pattern lines with a target address and at least one expiry directive.
Because Postfix supports TCP maps for virtual maps but not for aliases, patterns are matched against the full destination address (user@domain) not just the local address (user).
Example:
# this is the default port
port 9099
# this is the default window in seconds in which multiple queries from Postfix are considered a single query
grace 10
# any address beginning with "foo" gets sent to "[email protected]", expiring 48 hours after first use
/^foo/ [email protected] 48h
# the same but only works 3 times:
/^temp/ [email protected] 3x
# both at the same time (expires either after 5 uses or 7 days, whichever happens first)
/^paranoid/ [email protected] 5x 7d
# works only twice before expiring, but gets forgotten about after about 6 months
/^spy/ [email protected] 2x !180d
# default settings for any address - if set these directives are applied to all patterns unless overridden
* 10x !365d
If configured like the example above:
- configure Postfix to use
temp-email
(see below) - give out an address like "[email protected]" (in an online form, to a store cashier, to a person you don't trust with your regular email address, whatever)
- Postfix receives an email to that address; it's not a real local address so it sends a query to
temp-email
temp-email
does not have the address in the database so it checks it against the patterns in the config file, finds that it matches/^foo/
, so it:- records it in the database with an expiry date 48 hours in the future
- replies to Postfix with the given target address
[email protected]
- Postfix accepts the mail, rewrites the destination address and delivers as normal
The next time Postfix receives an email to this address it queries temp-email
again. This time:
temp-email
checks the database and finds an entry for[email protected]
. If the current time is earlier than the expiry date it:- returns
[email protected]
to Postfix - Postfix accepts the mail, rewrites the destination address and delivers as normal
- returns
- ...otherwise...
- returns unknown address to Postfix
- Postfix rejects the mail from the remote server
If you also give out "[email protected]" it will get recorded separately in the database with its own expiry date.
Postfix Configuration
Development
TODO Write development instructions here
Contributing
- Fork it (https://github.com/joatca/temp-email/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- joatca Fraser McCrossan - creator, maintainer