Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1086
  • Last Modified:

Mail forwarding syntax in .forward and/or procmail

Hello,

I have an ISP email account which has numerous email addresses forwarded to it.  I need to forward all mail destined for a particular address to multiple addresses.  My shell account has procmail installed, but I'm wondering if I can do this with a .forward file?  If you could provide syntax for the simplest way to accomplish this, I'd be most grateful.  (I don't know much about procmail, except that it can probably do what I'm asking.)

So, to recap, I'd like all mail that comes into my shell account for foo@blah.com, to be automatically forwarded to name@domain.com, name@domain2.com and name@domain3.net.

Any ideas?  Thanks in advance...
0
Fozzy_2000
Asked:
Fozzy_2000
  • 6
  • 3
  • 3
  • +1
1 Solution
 
AleeCommented:
Create the .forward file in you home directory.  Double check you home directory with command "echo ~".  Enter each email address on a different line.

your /home/foo/.forward file should look like this:
name@domain.com
name@domain2.com
name@domain3.net
0
 
yuzhCommented:
If you want to keep a copy of the eamil in your ISP server and forward the mail to the others, the .forward file looks like:

YourISPloginName, name@domain.com, name2@abc.net


0
 
Fozzy_2000Author Commented:
Thanks for the suggestions... I may need to clarify something though.  

Say, for example, the actual shell account name is "shellact".  Which would make the 'main' email address "shellact@shell.isp.com".  Now, through my DNS provider, I have a bunch of addresses forwarded to this account.  For example, let's say "foo@blah.com", "foo2@blah.net" and "foo3@blah.org" all forward to "shellact@shell.isp.com".

I *only* want to forward the email that comes into my shell account destined for "foo@blah.com".  Again, I want the email destined for foo@blah.com to be forwarded to multiple recipients: "name@domain.com", "name@domain2.com" and "name@domain3.net". I want the other forwards (foo2@blah.net and foo3@blah.org) to be received in the shell account as they already are.

An example of this application would be if I had an online ordering service and I wanted new orders to be forwarded to the various order-filling people (using the above example, all new orders would be sent to foo@blah.com).  Yet, I also wanted to receive my regular email at this same account (and of course didn't want that to be forwarded to the order-filling ppl).

Sorry if I wasn't clear enough... thanks again!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
yuzhCommented:
In this case, you need to write a filter script to handle the job.

your .forward file would looks like:

\shellact, "|/home/shellact/bin/mymail-filter"

In your "mymail-filter", you need to do the following things:

1. Catch the incoming email and store it in a tmp file.

2. Check if the mail is  for who, and process:

case "$RECEIVEDADD" in
  "foo@blah.com")
       mail the tmp file to whoever you want
;;
   * )
       #do nothing, and the mail keep in your mail box
       ;;
esac  

   I hope that the above infor can help.

   Have a look at my script in the following question, it should give you some idea on how to catch an incoming eamil and process it. (I ansered the question myself, cost you no points )

    http://www.experts-exchange.com/Networking/Email_Groupware/Sendmail/Q_20319762.html

   Cheers!

0
 
Fozzy_2000Author Commented:
Thanks for the info... I have no idea how to read that shell script that you posted, but I'll try to analyze / implement it.
0
 
yuzhCommented:
The script I wrote is for email auto-reply, not 100% want you want for you case.

If you don't know how to write a script, you can try to post a 500+ point question in UNIX programming TA, to see if any one want to spend some time to write one for you case (required know the email format and skill in shell script).

If you want to do it yourself, and you get stuffed in some point, you can post a commet here, I'll give you a hand.
0
 
GnsCommented:
Um, why haven't anyone done the procmail thing?

Yuzhs' mailfilter is good enough, true, but ... since you have procmail...
Is promail run globally, or called through the .forward file? If via .forward, then put
"|IFS=' '&&p=/usr/bin/procmail&&test -f $p&&exec $p -Yf-||exit 75 #YOUR_USERNAME"
in that file.

Create the file .procmailrc in your home directory, with content like this (you might want to set PATH, MAILDIR etc etc. Look at the excellent examples in man procmailex):
:0
* ^TOfoo@blah.com
! name@domain.com name@domain2.com name@domain3.com

-- Gl
0
 
yuzhCommented:
If you want to try the procmail thing, have a look at the following tutorial:

http://pegasus.rutgers.edu/~elflord/unix/procmail.html

0
 
GnsCommented:
Thanks yuhz... That was an (incomplete) accidental post by me (as can be seen by it's ... incompleteness:-).
The tutorial is great (as is the man-pages;-).

I've used procmail to accomplish exactly this kind of thing in the past... it works like a charm. I warmly recommend you to try.

-- Glenn
0
 
yuzhCommented:
I did read something about procmail in the past, I mainly interested in the auto-reply, from my memory the auto-reply is call the vacation program to do the job.

Unfortunately, vacation cannot handle my network situation (I have subnet,sub-subnet, as show in my link), that's why I endup wrote that script to do the job.

I think procmail might be good enough for Fozzy_2000's case.

Cheers!

0
 
Fozzy_2000Author Commented:
Thanks for the info and all of the responses.  It looks like procmail is the way that I'll be going.
0
 
GnsCommented:
Good choice.
Have fun
-- Glenn
0
 
yuzhCommented:
Hi Gns,

   You are the first one to make the suggestion to use procmail.

   To make it fair, I post the a question at:

http://www.experts-exchange.com/Operating_Systems/Unix/Q_20584485.html

   Cheers!

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 3
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now