Regex email?


#1

I’d like to be able to create a simple regex for email to a domain, so that I can make up mailing addresses that match the place I am registering as a user, on the fly. For instance: when I register on notsosecuresite.com I use zzznotsosecuresitedotcom@mydomain as my address. My mail allows it through because it begins with “zzz” or some other pattern.

Any suggestions on how to do this?

Maybe I should chill out instead and take the dog for a walk?

John


#2

I thought there was some disucssion of using "me+zzzsite@mydomain.com" since the plus acts like a transparent alias, but I recall from the discussion that some sites choke on the plus, or just discard it and what follows. But test it and give it a try.

Another option would be to create a subdomain, then set up a catch-all email address for that subdomain.

In addition, chilling and taking the dog for a walk will make you both happier.

-Scott


#3

I have something like this worked out.

First enable catch-all for your domain.
Then make a .procmailrc file in your admin’s home folder like shown below (you’ll need to modify it accordingly).

In this example, "admin@domain.com" is the admin w/ catch-all, and "name@domain.com" is the real e-mail address.
This will catch any "name-foo@domain.com" or "name+foo@domain.com" and forward to "name@domain.com".
It also puts anything to "admin@domain.com" into the normal mailbox.
Everything else is considered spam and is deleted.
Note that ‘+’ is actually an illegal character for an e-mail address, although only the most pedantic of apps will care.

Another cool thing to do is add a .procmailrc to the real account (name@domain.com) to strip the ‘foo’ and embed it in the subject. So an e-mail to "name-foo@domain.com" with subject “Bar” shows as being to "name@domain.com" with subject “[foo] Bar”. That’s the 2nd script below.

These probably aren’t perfect but so far so good for me.

======================================

Shunt name-foo@domain.com to name@domain.com

MAILDIR=$HOME/Maildir
SHELL=/bin/sh
LOGFILE=$HOME/procmail.log
VERBOSE=yes

Forward anything of “name[±]foo@domain.com” to name@domain.com

:0

Send anything to "admin@domain.com" to regular mail

:0

  • ^TO_name@domain.com
    $MAILDIR/

Flush the rest to /dev/null

:0
/dev/null

MAILDIR=$HOME/Maildir
SHELL=/bin/sh
LOGFILE=$HOME/procmail.log
VERBOSE=yes

Forward anything of "name-foo@domain.com"

to name@domain.com with subject “[foo] subject”

:0

  • ^TO_name[±].+@domain.com
    {

Get “foo” from To: address, and original subject

SRC = formail -x "To:" | tr '@' '\n' | grep -i name- | head -n 1 | tr '+' '-' | cut -f 2 -d -
SUB = formail -x "Subject:"
:0 fhw
*
| formail -I “Subject: [${SRC}] ${SUB}”
}
:0


#4

Hello oncebitter,
thanks!


#5

Awesome, thanks for the tip, and the URL for suggestions. There’s already one in there, called:

Allow “semi-catch-all” emails like “sales-*@domain.com”.

Go vote for it!

Thanks again, all.