View Full Version : e-mail forwarding question

07-03-2003, 12:34 AM
Is it possible to use wildcards when setting up e-mail forwarding? For instance, suppose I wanted all e-mail addressed to bob????@mydomain.com to be forwarded to an address, where ???? could be any number of characters. That way e-mail addressed to bob, bobby, bobisanidiot, etc. would go to that address. I tried using bob*, but doesn't work.


WestHost - CSimiskey
07-07-2003, 09:56 AM
No, the e-mail redirecting only works for static addresses, not dynamic like what you are looking for. My recommendation for you would be to use procmail to apply rules like this to your incoming e-mails. We do not provide any support for procmail, but you can find a great tutorial/tips here:

07-07-2003, 04:56 PM
This procmail stuff looks interesting. I'd love to give it a go. I tried accessing the mail directory (apparently /var/spool/mail/design64) but I cannot - it tells me the directory /var/spool/mail/design64 does not exist (even though when I have new mail it tells me that there is "new mail in /var/spool/mail/design64"). So I went into /var/spool/mail which does exist and tried an "ls", but was denied access. Anyway, could you please provide me with the location of the directory/ies necessary to play around with procmail? Where would I have to upload my .procmail file to (assuming I was using FTP to do this)?

If I mess something up, how can I revert to the mail settings as they are (untouched) now - do I just remove my custom procmail (or will I have to contact support to reset it)?

Finally, are the settings of a custom procmail seperate to the settings as they are now (e.g. redirects, etc.) or will I have to back those up and then overwrite them with my custom one?


WestHost - CSimiskey
07-07-2003, 05:31 PM
As stated previously, procmail is unsupported so we cannot give you definitive answers on most of your questions. With that in mind here are my answers:

1. Your mail is in the file named /var/spool/mail/username. You cannot access the directory /var/spool/mail.

2. The procmail file should go into your home directory (/home/username)

3. Remove the procmail file

4. Yes they are completely seperate.
4b. It is always a good idea to make a backup before you start playing with things on your account.

If you need further assistance with procmail I highly recommend using the resources listed at the bottom of the URL included in my original posts as there are people there that are a lot more knowledgeable that will be able to help you better.

07-08-2003, 12:48 AM
It looks like procmail is a bit more involved than what I'm ready for at the moment. But thanks for the info, maybe I'll look into it at a later time.

07-08-2003, 02:45 PM
web1x: if you find the guide recommended by Chris a little daunting, don't worry, you aren't alone. Even after following exactly as stated on that site, I got some troubling errors. Having spent about 6 hours trying to get my custom procmail settings working, I finally got it done. And believe you me, it was worth the effort. I am confident I can restore my e-mail box to near-spam free levels (currently I receive 60+ spam e-mails a day on it). The great thing is, I don't even have to delete those e-mails I filter out - I can save them in a folder and use pine to read through the less suspicious looking ones once in a while. Enough rambling, here are some tips I'd like to point out to you and anyone else that wants to harness the power of procmail.

Before I begin, let me stress I am no pro at this stuff... All that I know is from playing around :D As Chris stated, back up your stuff, and only do this if you aren't expecting any critical mail, etc. because if you do stuff wrong, you could lose incoming mail.

1) Here is a much easier-to-read guide on procmail: http://simonbs.com/procmail.html Though not as detailed as the one Chris pointed out, it helped me get started quickly and relatively painlessly. Another easy to read guide (if a little dated): http://www.stimpy.net/procmail/tutorial/

The next two points are key. If I had known about these (or maybe read the help sites properly) I wouldn't have wasted 6 hours ripping my hair out...

2) Westhost config is such that you do not need a .forward file as stated on all of these procmail guide sites. So, don't bother with it. All you need to do is make your .procmailrc file and put it into your /home/username directory (one level up from your regular www directory).

3) CHMOD .procmailrc 644! If you don't do this, it's not read (nothing is done - no errors, no filtering, nothing). This is the reason I'm nearly bald now. Make sure to upload it in ASCII format.

4) Some of those variables these sites say you need at the top of your .procmailrc file seem to be redundant on Westhost. Of course, you may need them if you intend diverting your mail to a script or something "more advanced" like that (e.g. the PATH may need to have been set), but if you are just doing some plain filtering like me, all you need to set are these 2 variables:


This way, you have an accesible log of all the actions that procmail has taken on e-mails (in this case called procmail.log and located in your home/username/mail directory). Using SSH, you can do a "mailstat procmail.log" (without quotes) to get some stats on this (do a "mailstat -help" for more detailed help on this). Or you can look through the log itself in Notepad or any text editor for a more detailed look (listing of the action taken with each and every incoming e-mail).

Please note that after playing with procmail a little more, I have decided to slightly modify the following point (as well as the addition of the second variable (MAILDIR) above).

5) I recommend moving your filtered e-mail to data files (previously, I called these folders - and the way I had set my procmail up, they were folders with each e-mail being a randomly named text file) so that you can access it (the data file) as you would a mail folder in Pine - just in case you pick up in your log that it moved some legitimate mail. Do remember though, that doing this will save all filtered mail - meaning it will be wasting space, so you will occasionally need to look through each of your "mail folders" and delete messages contained therein (I use SSH and Pine to browse through and delete these e-mails two or three times a week, but this for you will depend on how much e-mail you get). What I have done is set up a rule that sends all mailed marked by Spam Assassin as possible spam to "spam":

* ^X-Spam-Flag: YES

Though some sites do not recommend "deleting" this mail (because it may be legit), I have yet to find Spam Assassin make a mistake in identifying spam on my incoming mail. This may or may not be the case for you. Besides, I look through this mail (From, subject, etc.) once a week to make sure it truly is all spam before deleting it forever.

6) Contrary to my above post, you don't actually need to do anything with that /var/spool/mail/username stuff. Again, this may depend on whether you are doing some of the more advanced stuff, such as redirecting to a script, etc. Read through the various FAQ/sites and the manpages.

Anyway, I think that's about all that I need to mention. There are a lot of guides out there on procmail: most of them very daunting and not user-friendly, but the two I mentioned above should get you started.

Hope this helps :wink:

07-09-2003, 12:52 AM
Thanks design64! Those links did make it much clearer. I'm thinking that all I need to do is make a .procmailrc file like this:




Would that be correct?

07-09-2003, 07:12 AM
You're very welcome, web1x. I tried the code you had up, and it works fine just fine for me. Just a note though, add a space between the * and its following code and the ! and its following code like so:


* ^TO_bob.*@mydomain.com
! bob@hisdomain.com


I didn't test if it works without the space, but you might as well do it with the space anyway :) If you want to keep a copy of the mail on the server too (i.e. leave a copy as well as forwarding one), change the first :0: to :0c:

07-09-2003, 01:32 PM
Thanks again! What's the difference between :0 and :0:? I read something about a lockfile in the man pages, but I don't understand when and why would would you use it.

07-09-2003, 04:14 PM

I didn't think that extra colon made a difference (except being 'more correct' than using one colon), hence I suggested it. But looking through my procmail log today, I see a few errors, and this site explains them: http://rhols66.adsl.netsonic.fi/era/procmail/mini-faq.html#implicit-lock

So, maybe it is best to leave out that second colon unless you are using flags and/or a specific 'lockfile' (if all you have in your procmail is that forwarding code above, then leave out the second colon). Sorry about that :( Check out the other FAQs on that site - they're pretty useful!

Anyway, have you managed to set it all up (and get it working) as you needed to?

Before I forget, I'd like to draw everyone's attention to my above (extremely lengthy) post - I've made a few changes to my first post you may want to take note of before/if you take my advice.


07-10-2003, 01:40 PM
Yes, that link does clarify the lock file issue, thanks!

I haven't set it up yet. But I'm pretty confident that I can get it going when I'm ready, with the info you provided. Thanks again!

09-02-2003, 01:35 PM
* ^X-Spam-Status: Yes

worked for me