Forward emails with extensions


Do you know if it’s possible to forward email sent to an address like

DreamHost’s postfix configuration doesn’t seem to look for files named .forward+extension and besides other forward files like .forward or .forward.postfix are ignored when an email arrives with that kind of address with an extension.

Any idea to solve this?

David R.


Have you tired:

  1. set up “forward-only”/alias to the machine mailbox (ie - this is not a ‘hosted email mailbox’)
  2. Use procmail to check headers for extension and forward?

See under “Using Procmail to Forward all Shell Account mail to an External Address” to see if that will work for you.

This does mean that the procmail has to process all messages for name@domain, not just name extension@domain

Edit: I’ve confirmed this works for the most part with a SHELL user

  1. Find the name of your web server.
  2. Setup forward-only address: username@domain ->
  3. Send message to username+extension@domain
  4. Login into shell
  5. Change to ~/Maildir/new
  6. You have mail! (run the ls command to see filenames of each message)
  7. The message headers retain “To: username+extension@domain”

So we just need to add a recipie to forward to another email address…

:cool: -//-


Ok, I understand what you’re saying. In fact, that was my idea, to use procmail to filter email by its “To” field.

I’m having no problem receiving email messages sent to username+extension@domain and the header is kept as you say. My problem is that I can not launch procmail, because the only mean I know to do this is placing a pipe in the .forward file in my shelluser’s home as described in the wiki ("|/usr/bin/procmail -t"). But the forward file seems to be ignored when there is an extension. Am I doing something wrong? Is there another way to do this?


No, this should work. Besides procmail, you can pipe the message to any other program. So I wrote a Perl script and it works just fine for me (the Wiki has example scripts for other languages).

And if I have it pipe to procmail, it works for me too.

Are you putting the pipe in a file named .forward.postfix ? Also check to make sure you aren’t using the wrong linebreaks if you edit the files on Windows, and make sure there is a linebreak at the end of each line. You might want to make sure the .procmailrc file has PATH, MAILDIR, LOGFILE, SHELL, etc set.

:cool: -//-


You’re right.
I missed the most important step: I had a “Fully hosted Email” instead of “Forward-only Email” and for that of course it would skip the .forward file in the shelluser’s home, because email account and user are not related. Stupid mistake, I know…

I’ll try a python script :slight_smile:
Thanks for quick help.