Web Hosting Talk







View Full Version : email to execute a script


choon
02-07-2002, 01:31 AM
Hi everyone,

Anyone can explain on how to setup a forwarder without using a control panel as I want to learn. I am using a Cpanel/WHM server. Is it create a .forward file and upload to the root directory of the user account? What is the format in the .forward file?

By the way, how to I execute a script whenever a given email address receive an email? Is it using .procmailrc? How :confused:

Thanks.

Kindest regards,
Choon

freakysid
02-07-2002, 09:12 AM
What is your mail server? Sendmail? Anyway, I know that postfix supports sendmail style .forward files and I am pretty sure that qmail does to.

So it is simply a matter of uploading a text file named .forward to the user's home (root) directory wherein you pipe the mail to a script. Example:

|/path/to/script/to/pipe/email

And that's it! the email will be available to the script from stdin.

But that is assuming that the mail is being delivered to is that of a system user, which your post implies (ie, not a virtual mailbox).

Additionally, you can also redirect email to a program within your virtual user database (depending on which email server you are using this will be named differently). That is you can do

user@domain.name |/path/to/script/to/pipe/email

in your virtual account file and of course rehash the file and reload the server (if necessary). But you see, I use postfix, so I am not sure of the specifics of your mail server.

choon
02-07-2002, 02:56 PM
Hi freakysid,

Thanks for your help :D

The server is using sendmail. It is using WHM/Cpanel Control Panel. I have tried to create a .forward file and upload it into the user root directory but I am not very sure about the format. Is it as below:

support@hosteddomain.com, info@myotherdomain.com

Is it separate by a comma or just a space or what?

For execute a script, I will try the following format:

myexecemail@myhosteddomain.com, "|path/to/email/handler.pl"

Is it correct or without those comma and quotes?

Once again, thanks for anyone who response :D

Kindest regards,
Choon

The Prohacker
02-07-2002, 05:33 PM
To do this:

pico /etc/valiases/myhosteddomain.com

And add:

support@myhosteddomain.com: "|/path/to/script.pl"


Just to clairfy, Cpanel doesn't use sendmail, it uses Exim....

choon
02-07-2002, 10:08 PM
Originally posted by The Prohacker
To do this:

pico /etc/valiases/myhosteddomain.com

And add:

support@myhosteddomain.com: "|/path/to/script.pl"


Just to clairfy, Cpanel doesn't use sendmail, it uses Exim....

Thanks and my bad... yes, you are right... it uses Exim (I remember seeing it in WHM).

Can I edit the /etc/valiases/myhosteddomain.com file as I am just a reseller?

Regards,
Choon