Reply to PEAR mailing problem

Your name:

Reply:


Posted by MJ on 01/30/07 12:31

I use the following code to send mails using php usinf PEAR package.
When I run this code from command line using the command "php
automaticMail.php" the code works fine.
But when i run this script from browser it give the error :
Starting..... Error sending mail: (unable to connect to smtp server
10.110.8.212:25) End of Program

I am not figure out how this could happen ??? Sam code runs from
command line sending mails correctly but not through the apache
server.



<?php
require('Mail.php');
require_once 'PEAR.php';
echo "Starting.....";
$smtp_server="HOST";
$smtp_port="25";

$headers["From"] = "$from";
$headers["Reply-To"] = "$replyto";
$headers["To"] = $recipients;
$headers["Subject"] = "$sub";

$msg = "test";
$params["host"] = $smtp_server;
$params["port"] = $smtp_port;


if (PEAR::isError($mail_object = Mail::factory('SMTP', $params)))
{
echo "Failed to create PEAR::Mail object\n";
die();
}

if (PEAR::isError($send = $mail_object->send($recipients, $headers,
$msg)))
{
echo "Error sending mail: (". $send->getMessage() .")";
}
else
{
echo "Mail sent ". count($recipients) ." recipients.";
}

echo 'End of Program';
?>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация