top | item 30981429

(no title)

ohlookabird | 3 years ago

Nice! I do something similar, but using an automatic aliasing scheme so that I don't have to manually configure an email address for each service and other users can use this without me knowing their aliases. In my setup, aliases can contain wildcards, represented as percent signs. If an alias phil.%@domain1.com is set up, all your examples will be sent to the respective aliased address. I use Postfix Admin with a MySQL database. Hence the Postfix setup looks like this:

    virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf,
                         mysql:/etc/postfix/mysql_virtual_alias_maps_wildcard.cf,
                         hash:/etc/postfix/virtual
The first file is just regular aliases, and is basically a simpler version of the second file (no SQL selections/filters) and could also be merged into a single query with the second file:

    user = mail
    password = <password>
    hosts = 127.0.0.1
    dbname = maildb_postfix
    query = SELECT a1.goto FROM alias a1
            LEFT JOIN alias a2 on (a2.address = '%s')
            WHERE '%s' LIKE a1.address
            AND a1.active = '1' AND a2.address IS NULL
This works, because the percent sign in the alias is picked up by the LIKE keyword. A setup like this allows me to configure many aliases through Postfix Admin's web admin page, including optional wildcard aliases (depending on which users wants that). It has been working very well for me over the past 15+ years. Also, I haven't looked at that SQL query since then and would likely write it in a nicer way today.

Note: with the above code SQL injection could be possible through an alias name, but given that in this setup I am the only one managing the mail accounts, I was willing to take this risk. :-) Postfix Admin might do some cleaning/validation, but I haven't checked on it.

discuss

order

hackernewds|3 years ago

Why not just use phil+craigslist@gmail.com or phil+kmart@gmail.com? same effect and lands in the same phil@gmail.com address

ratww|3 years ago

Because it's not as effective if the goal is to catch spam. Spammers are already wise to the meaning of + and will strip it automatically when selling data in bulk. Plus, some services block creating accounts with the + or with their name in the address.

ohlookabird|3 years ago

How do you mean? This is exactly what I can do with my setup. If you are referring to the use of Gmail: I prefer to run my own infrastructure as long as this is possible.