Home > Personal > Sendmail & Mailman on my terms ;)

Sendmail & Mailman on my terms ;)

So the ISP I use for hosting (westhost) uses sendmail as its default mailing client, which is fine and dandy.  I moved over to an external host about a year ago now, in hopes to minimize some of the time and work I was spending hosting my own server at my own home.  Westhost gave me the control I still wanted via a virtual private host where I can install apps, configure some server level details, etc… but I no longer have to worry about the hardware, or os upgrades, etc…  Works well.

Well – when I was hosting things myself, I came to like qmail – more specifically I really liked one built-in feature of qmail.  When I setup email accounts, each account automatically received all emails sent to it, and to any email in the form username-anythinggoeshere@domain.com.  For example — if you sent an email to todd-bestbuy@gileszone.com — it would just go directly into my todd@gileszone.com account.  And yes, that was my main use for this, to give out new email addresses to various online stores, etc… so I could better filter, and know which ones gave my email addresses over to others w/out my permission.  Several of my siblings also enjoyed this feature, and used it widely… so when I switched over to sendmail on this new host — I had to figure out how to get this same functionality (or many emails would not be directed into their proper home).

Turns out that sendmail does a very similiar thing out of the box, but they decided that the + symbol is the one to use, not the -.  So todd+bestbuy@gileszone.com worked as I wanted it — problem is, that is not the email address that best buy has on record (and it also invalidated many other email addresses I’ve given out).  Well — after searching far and wide, and coming up to speed on sendmail, and the intricacies of its configuration file, rulsets, maps, etc… I came across a fairly straightforward addition to the sendmail.mc file to get the behavior that I wanted (thanks to google, and other geeks before me).  A simple addition of the following lines did the trick:

Kplus regex -s1,2 -d+ ^([0-9a-z]{1,64})-([0-9a-z]{1,64})$
R$+ <@$=w.> $*  $: $(plus $1 $: $1 $) <@$2.> $3

It turns out that what the above ends up doing is simply replaces the ‘-‘ character in the part of the email address that comes before the ‘@’ with the ‘+’ character, and then sendmail default behavior takes care of the rest.  I won’t bore you with the gory details, but trust me ;)

Ok — so I also wanted to keep our email lists going that I had on the previous server, and I decided to use mailman for the mailing lists.  Everything was all working fine, except for one small detail — moderator and owner emails to the list where not being sent out.  I didn’t have time to look into at the time, but finally got back around to it this week.  It appeared that all the emails sent to the moderators or owners of the list just dissapeared, never reaching their intended destination.  Well — as luck would have it, my fix to make todd-bestbuy@gileszone.com work, broke mailman.

Mailman uses aliases such as listname-owner@domain.com, or listname-subscribe@domain.com to interact with the mailing list (there are others of similiar form as well).  Well — my earlier fix ended up making any email sent to listname-owner@domain.com to be sent to, yes listname@domain.com.  Ooops!  I had to figure out a fix, so I could start getting my moderator emails going again, and having subscribe emails and unsubscribe emails work (amongst other things).  So back to my good friend google…

… but google didn’t find the solution this time, although it did offer enough information for me to hack together a solution.  In the end, I modified my sendmail.mc file to only do the username-anytext@domain.com –> username@domain.com rewrite if the username was an actual user on my system (i.e. in the /etc/passwd file), otherwise — leave it alone.  It’s working great now, and I can finally go back to sleeping good at nights :)  Here is my final hack (as of now), in case this is helpful to others out there:

Kcheck regex -s1,2 ^(([0-9a-z]{1,64})-([0-9a-z]{1,64}))$
Kplus regex -s1,2 -d+ ^([0-9a-z]{1,64})-([0-9a-z]{1,64})$
R$+ <@$=w.> $*  $: $(check $1 $: $1 $) <@$2.> $3
R$+$|$=l <@$=w.> $*     $: $(plus $1 $: $1 $) <@$3.> $4
R$+$|$~l <@$=w.> $*     $: $1 <@$3.> $4

It’s fun being a geek sometimes ;)  Satisfying to finally bend sendmail and mailman’s will to my own…

Categories: Personal Tags: ,
  1. No comments yet.
  1. No trackbacks yet.