PDA

View Full Version : PHP and Sendmail to catch and forward mail?


sir pannels
11-27-2004, 03:31 PM
Hey all :)

Have been planning a script for catching and forwarding email, I have planned it out and confirmed with others that it is indeed possible and the most viable method of doing what I need here, but I need some snipplets of code/structured english to get me started on the actual script.

The idea is , email can be sent to any alias at domain.com, so me@domain.com or stuff'@domain.com and so forth, so the actual alias is ignored initial as the mail is sent to the domain.com - what I need is for sendmail to catch that email and send it to a DB where the primary key will be the alias.

So for example if you were to send an email to jimmy@domain.com the script would take the email message, sender etc and INSERT INTO db WHERE alias = jimmy.

Now the database qry and formatting I can do, the bit I need help getting started with is the code to catch the email and send the results to a script for me to run insert qry etc.

Anyone on my level here or did that WHOOSH over your head like it did mine the first time I discussed it? :)

Thanks,
P

fci
11-27-2004, 05:02 PM
we did something vaguely similar to that where I work but I wasn't directly involved in setting up the pipe.
here is an article about it though:
http://www.evolt.org/article/Incoming_Mail_and_PHP/18/27914/

sir pannels
11-28-2004, 02:31 PM
Thanks very much frci - that is exactly what I want... form that article I'm using...


james@xxx.com,"|/mail/script.php"


which sends any mail to that script and also sends a copy of the mail to another address.

On test - the mail gets send to the forwarding email so thats great however I also get a auto mail that reads..


A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

pipe to |/mail/script.php


Now, mail/script.php does exists, you have any ideas why it doesnt like the pipe to?

cheers.
P

sir pannels
11-29-2004, 01:57 PM
A thought here is that the message is saying PIPE TO |

Why would it pipe and then have a pipe character, maybe it puts the pipe there already - I shall try again and not use a pipe and tell you guys how it pans out :)

fci
12-01-2004, 12:34 PM
try this, only a guess though:
pipe to |/mail/script.php /dev/null 2>&1

sir pannels
08-07-2005, 11:56 AM
This is an old post... this project was on hold, never meant to be on hold this long though :D

Thanks fci, that did the same.. I have no error now.. using..

james@xxx.com,"|/mail/script.php"

But also, I don't gt the forwarded email.

I have cpanel on the host, is it possible that stops the .forward from working? As it seems to be doing nothing currently?

Cheers,
Sorry it took so long getting back on this.