I have a pipe script which pipes the email's to PHP.
I want to forward the email to the correct username
for example
user01@mydomain.com receives an email from
user02@mydomain.com, I want the script to take the user01 and search the database for the forwarding email and then send it??
I am really new to this bellow is a very poor attempt which I know I have all wrong..........
PHP Code:
// from = there email
$from = "email@mydomain.com";
// to = there username
$to ="$username";
// me= machine host name
$me = php_uname('n');
// host= smtp server
$host = 'localhost';
// msg= the original email message
$msg=$email;
// forward is the email address i want to forward to
$forward=$data=mysql_query("SELECT * FROM users where $username='email'")
or die (mysql_error ());
$info=mysql_fetch_array($data);
{
echo ".$info['email'];
}
require_once '../../SMTP.php';
if(!($smtp = new Net_SMTP($host, 25, $me)))
die("sending mail failed to initializen");
if(PEAR::isError($smtp->connect(30)))
die("sending mail failed to connectn");
if(PEAR::isError($smtp->mailFrom($from)))
die("sending mail failed to set from address [$from]n");
if(PEAR::isError($smtp->rcptTo($to)))
die("sending mail failed to set RCPT TO [$forward]n");
if(PEAR::isError($smtp->data($msg)))
die("sending mail failed to set data and sendingn");
$smtp->disconnect();
Any help would be great