.forward and alias mail forwarding questions


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers .forward and alias mail forwarding questions
# 1  
Old 01-28-2006
.forward and alias mail forwarding questions

I am trying to configure sendmail to forward email to a PHP script. I don't know UNIX and am having trouble figuring out how to forward the mail. I think this is just a bunch of basic questions, but I have had little luck getting help elsewhere on my specific questions and it's driving me nuts. You can see the instructions I am trying to follow here: http://www.devarticles.com/c/a/PHP/I...ail-and-PHP/1/

The instructions say I need to do 3 things:

1) forward email using either a ".forward" file or a modified "alias" file (the preferable method, if I have "root access")

I want to use the alias file, seeing as it's the preferred method. Supposedly the alias file should be found in my /etc directory, but using shell access to my site I see no such file in the /etc folder off the top directory. Am I looking in the wrong place? Do I have to create it? If I want to create/modify the alias file to forward mail sent to script@myurl.com to "|/our/script.php", what specific command do I use?

With regard to the .forward file, I've been wandering around among the directories trying to find my mail folder so I can put the .forward file in there, but I have no idea where it should go.

2) Now the instructions say "Since our script will function as a shell script, the first line should contain the path to the PHP CGI program. This is most likely located at /usr/bin/php of /usr/local/bin/php. This tells the operating system that this script must be parsed by PHP."

I'm sorry for asking such a stupid question, but what does the "of" in "/usr/bin/php of /usr/local/bin/php" mean? I see a file "php@" in the directory "/usr/local/bin/php" but I do not know what is meant by "/usr/bin/php of /usr/local/bin/php". Also, how do I tell that PHP is compiled as a CGI module?

3) Once I write and save the script, I must put it in the correct location, and make it executable with "chmod 755"

Googling chmod, my understanding is that to do this, I navigate to the directory my script is in, and type "chmod 755 script.php" Is that right?

Thanks for your help.
# 2  
Old 01-28-2006
1. There are many versions of unix and many versions of sendmail. It is cast in concrete that sendmail is in use, but it is the most popular MTA. You need to figure out what version of unix you are using. "uname -a" should tell you that. The alias file could be almost anywhere. I doubt that it is directly in /etc. But /etc/mail might be a possibility. I have never seen sendmail running without an alias file in existence. Sendmail is required to support the postmaster alias and it can't without an alias file. But note that your doc says .forward is in your home directory. No version of sendmail will put it anywhere else. It is not unusual for .forward to not exist. So simply create it.

2(part 1). Gotta be a typo. Instead of "of", it should say "or".

2(part 2) and 3. I am not a PHP expert or a web expert. But there are decisions that were made when the web server was set up. You are assuming that CGI scripts are going to work. CGI can be turned off. If it is turned on, it will probably be required that CGI scripts be in some particular directory. You need to move your script to that directory. But yes, you have the chmod command right. Note that "CGI module" was not one of the two choices the author offered. I am not sure how to tell the difference between CGI binary and Apache module. But of all this involves reverse engineering installation decisions. You might consider posing some of these questions to the guy who configured your system. Or maybe some PHP/CGI expert will come along here with some wisdom. Good luck.
# 3  
Old 01-29-2006
OK unfortunately I am still having some issues

1) Someone suggested I find the aliases file with "find /etc -name aliases -print", but it returned no results. (I was in the top directory)

I then tried "find -name aliases -print" and got the following results:

dgodshalk:/$ find -name aliases -print
find: ./home/aschwartz/.ssh: Permission denied
find: ./.renv/etc/default: Permission denied
find: ./.renv/tmp: Permission denied
find: ./.renv/var/lib/mw: Permission denied
find: ./.renv/var/spool/cron: Permission denied
find: ./.renv/var/state/sasl2: Permission denied
./.renv/usr/lib/perl5/site_perl/5.6.1/i386-linux/Unicode/Map8/maps/aliases
find: ./.renv/usr/share/doc/sablotron-1.0: Permission denied
./.renv/usr/share/doc/bash-2.05/startup-files/apple/aliases
find: ./.renv/usr/share/ssl/CA: Permission denied
find: ./.renv/usr/share/fonts/cmpsfont: Permission denied
./.renv/usr/share/texmf/aliases
find: ./.renv/root: Permission denied

So there are three aliases files, and I don't know which one is the right one (if any). I assumed I was using Sendmail because in my hosting provider's FAQs they make reference to Sendmail. (I am hosted on modwest.com)

Anyway I will try with a .forward file. I understand (perhaps wrongly) that it should go in the folder named after a given user in the home directory. I want to create a new user for this, so that mail does not get forwarded for an existing user. I searched around for 'create new user' commands in UNIX on google and found adduser, but trying to use it returns:

bash: adduser: command not found

So next, I create an new email account using my hosting provider's CP, and create a folder in the home directory corresponding to this user account, and create a .forward file in this home directory using pico. Strangely, I cannot see the .forward file I created (because it begins with a period, perhaps?), but if I try to save it again I get an overwrite warning, so I know it is there. The .forward file I created contained an email address instead of a link to a script, so that I could confirm that it was working. It is not working, so obviously I am still completely misunderstanding some part of this process.

2) I found the full path to php using the command

ls -l /usr/bin/php

which returned

lrwxrwxrwx 1 root root 18 Feb 17 2005 usr/bin/php -> /usr/local/bin/php*

even this is confusing to me. what does "usr/bin/php -> /usr/local/bin/php*" mean? which one is the path? there is a file called php@ in the former directory (along with a billion other files), and there is a file php@ in the latter directory also (along with a smaller number of files, many of which look like various versions of php, including php-5.0.4, php-5.0.3 etc.).

I checked my version of UNIX as you suggested by using "uname -a", so for what it's worth, this returned:

Linux pintlar.modwest.com 2.4.20-mw13 #1 Fri Dec 5 16:27:24 MST 2003 i686 unknown

Thanks for your help so far. I will continue to hunt around for solutions to these problems, and look forward to any additional suggestions you might have that will help determine the right aliases file and get .forward to work. I have a feeling these things are not so complicated, but so far this has been somewhat confusing.
# 4  
Old 01-29-2006
2. That is a symbolic link. So /usr/bin/php is just an alternate way to open /usr/local/bin/php. Two paths to the same file...sort of.

1. Those permission denied messages mean you are not root. You won't have the power to edit aliases should you find it. Nor can you run adduser. And yes, files that start with a dot are hidden to a limited degree.
ls -la
will let you see them.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Forwarding mail via Pine

I am asking about my work account, running Linux on a system server. On pine, I set up a forward to another email account. I also keep a copy in the original account. The forward has been running fine for some time. I believe the system sends the mail first to the forwarded account and then puts... (0 Replies)
Discussion started by: BLabel
0 Replies

2. UNIX for Dummies Questions & Answers

Forwarding Mail in AIX 5.3

Hello everyone, I am trying to create a forwarding scenario, and I do not seem to get it right! I created a .forward file in the directory where my personal mailbox resides. In the file is the full address to deliver email to ... yet the emails do not seem to get forwarded. Is there something... (3 Replies)
Discussion started by: gio001
3 Replies

3. UNIX for Dummies Questions & Answers

.forward for forwarding emails

Hi, I want to forward my emails to a different email account on Unix. I created a .forward file with just one line in it. forward_to@yahoo.com The emails are not getting forwarded to the forward_to email address, instead they are going to my original inbox. Is it required that I run the... (1 Reply)
Discussion started by: foxtron
1 Replies

4. AIX

Forwarding already received mail?

Greetings to all of you. I am a tad desperate here. I have found MANY articles scattered across the internet from google searches and unix.com searches for how to forward mail that say: Create a ~/.forward file and put XXXX in it. This is not what I need to do. We have bunch of users... (1 Reply)
Discussion started by: DennisC31
1 Replies

5. Solaris

mail forwarding

Hello everybody, I have solaris 10 running on SF v890, I need to forward some sepecific root mails resulted from some application, (or all root mails) to other machine running Solaris 10 also. does it have anything to do with mail relay, or just change the log settings??? Thanks in Advance... (1 Reply)
Discussion started by: aladdin
1 Replies

6. Solaris

how to forward mail in /var/mail/username to external mail

Dear All, Now I use solaris 10 and I try to forward mail from /var/mail/username to their external mail so what should I do? thank u in advance (2 Replies)
Discussion started by: unitipon
2 Replies

7. Solaris

forward root mail

how can i forward roots mail, i want every mail fowarded (1 Reply)
Discussion started by: csaunders
1 Replies

8. UNIX for Dummies Questions & Answers

.forward file for mail redirection

I've set up a .forward file on a few identical servers that we have (all identical .forward file as well) but only one server is forwarding any of my unix mail (mail generated by cron) to my internet account. Because these servers (5) are all identical in terms of aix versions, etc., I do not... (3 Replies)
Discussion started by: giannicello
3 Replies

9. UNIX for Dummies Questions & Answers

Sendmail - forwarding mail

quick question. I have a webserver that has various scripts for user registration and ect on it. I want to post (mail) these to myself - however I am a bit stuck on how to configure sendmail to do this. The hosting partner that I use has provided me with the use of their relay to send on the... (1 Reply)
Discussion started by: warrend
1 Replies

10. UNIX for Dummies Questions & Answers

E-mail forwarding

Hi, I would like to set up an E-mail forwarding service like Netaddress whereby users would be able to create an E-mail account in my domain name and have all the mail sent to that account forwarded to an alternate address they specify. I know that I can redirect mail sent to my domain using... (1 Reply)
Discussion started by: BigBro
1 Replies
Login or Register to Ask a Question