Web Hosting Talk







View Full Version : forwarding incoming mail to a processor


Angelo
06-16-2004, 03:25 PM
Hello,

I am currently working on a support system to be used personally by me, not aiming to be commercial. I have done the web interface as well as databases. But also i want to have the option to ticket opening via e-mail.

I think i need to add a forwarder to the support e-mail adress to a cgi/perl file. I do not have much info on them. Can i add a forwarder to a php file (i guess no). Also when i try to add the forwarders for example like:

support@xxx.com -> "home/user/public_html/cgi-bin/x.cgi"

It tries to send to home...../x.cgi@xxx.com and bouncing :)

I also tried to add it manually through /etc/valiases but still did not work.

Any recommandations?

Aras

ambirex
06-16-2004, 04:56 PM
this will be like mailman or majordomo, and assuming you are running sendmail.

1st, you will probably need to create a sybolic link in sendmail's smrsh directory to the script.
[/etc/smrsh]# ln -s /home/user/public_html/cgi-bin/x.cgi x.cgi

then, add this to your aliases file
support: "|/home/user/public_html/cgi-bin/x.cgi x.cgi"
( if you need someone to be copied on this email you can add:
support: "|/user/public_html/cgi-bin/x.cgi x.cgi", joe_the_support_guy )

then when mail is received it will be piped to x.cgi.

this is all from memory, so you will probaby want to check my work.

Angelo
06-16-2004, 06:13 PM
Nice work ambirex thanx, i will check these out. What about this e-mail passes any variables to the cgi file i can use? For the mail layout, coming address etc.

lwknet
06-17-2004, 12:58 PM
Originally posted by fcarsenal
Nice work ambirex thanx, i will check these out. What about this e-mail passes any variables to the cgi file i can use? For the mail layout, coming address etc.

i'd also liek to know

by <STDIN> ?

by $ENV{} ?

by socket ?

thanks

Angelo
06-18-2004, 09:56 AM
Instead of trying to do that with cgi i tried using php which i already know. I think it is working. I added an alias which point a php file. Taking it with stdin like;


#! /usr/bin/php
<?
$fd = fopen("php://stdin", "r");
$email = "";
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);
?>


The only error is that it processes the file but also bounce a "can not be delivered" mail to the subscriber. I can not find the way to prevent that.