Best Mail Setup to Just Forward Email?

I would like my linode to simply forward all mail sent to it.

However, I will be munging various subject lines.

I'm doing this so I can have email aliases setup like en-work@example.com, and any email sent to that would add "#work" to the subject so it'd be sorted correctly at Evernote. Same thing for Toodledo, etc.

Some email addresses will just forward as-is.

So…what is the best way to do this? procmail for the munging but what should I setup as far as the mail program itself?

3 Replies

Have you looked at the library?

http://library.linode.com/search?query=smtp

I generally use Postfix for mail stuff, so I'd lean towards that. Something I threw up awhile back to change the envelope sender of forwarded mail (to avoid tripping out SPF) defined a transport:

/etc/postfix/virtual

...
rtucker@example.com rtucker+example_com@gmail.com.munger
...

/etc/postfix/transport

.munger   munger:

/etc/postfix/main.cf

munger_destination_recipient_limit = 1

/etc/postfix/master.cf

...
munger  unix  -       n       n       -       -       pipe
  flags=q user=nobody argv=/etc/postfix/redirector ${mailbox}@${nexthop} ${original_recipient}
...

/etc/postfix/redirector

#!/bin/bash

# Redirects mail to make SPF happy.
# Ryan Tucker <rtucker@gmail.com>, 2010 Oct 24
# Based on http://serverfault.com/q/82234/54177
HOSTNAME=`hostname -f`
DESTINATION=`echo "$1" | sed 's/.munger$//'`

/usr/sbin/sendmail -bm -f "mail@$HOSTNAME" "$DESTINATION"
logger -i -p mail.info -t redirector "Redirecting message to $DESTINATION (orig to $2)"</rtucker@gmail.com> 

I thought it was pretty clever: to route mail through it, just append .munger to the recipient e-mail address. You could do something similar without having to do a lot of manual configuration, if you wanted to dedicate something.example.com to the job… en.example.com pipes through procmail to add "#${MAILBOX}" to the subject, so work@en.example.com would add #work, etc.

Or, search for docs on setting up postfix+procmail and someone'll probably have your use case ready to roll. :-)

Instead of munging subject lines, couldn't you just add a custom header you can use to filter with your client?

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct