I've been trying for hours to make a php script work, but I'm getting nowhere.
What I would like to do is having emails forwarded from a .forward file to a php script. The php script is then supposed to take the sender email, subject, body and headers and place into a mysql database.
I have set up the .forward file and as far as I can tell it's working: when I set it up with a php file that doesn't exist, the email is returned to me, but it doesn't do this now. However, nothing happens at all when I try to send an email. It's like it doesn't execute the script. I've tried to set it up to do something no matter what the email contains, but it doesn't help.
I am trying to use a slightly modified piece of code I found in this board:
Code: Select all
#!/usr/bin/php -q
<?php
//read in the message from the command line (sent to us by the pipe)
$message = $argvї1];
//split the message by EOL to parse the header
$messageList = split("\n",$message);
//Database connection
mysql_connect("localhost", "**user**", "**pass**");
$dd = mysql_select_db("**db**")
or die("Could not select database");
$res = "INSERT INTO `test` ( `from` , `subject` , `headers` , `message` ) VALUES ('$mailheaderїreply]', '$mailheaderїsubject]', 'c', 'd')";
echo $res;
$result = mysql_query($res)
or die("Query failed2");
?>Looking forward to hearing from you - and thank you,
Jesper