By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,744 Members | 1,716 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,744 IT Pros & Developers. It's quick & easy.

PEAR mailing problem

P: n/a
MJ
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';
?>

Jan 30 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
MJ
Kindly lemme know if any1 has any ideas on wht cud be wrong :(

MJ
MJ wrote:
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';
?>
Jan 30 '07 #2

P: n/a
MJ wrote:
Kindly lemme know if any1 has any ideas on wht cud be wrong :(

MJ
Hi,

We will.
This is a hell of an active usenetgroup.
I think nobody knows what is wrong.

I never use PEAR MAIL, but I would first try to send via php's own mail
function to see if you can send mail with that.

http://nl2.php.net/manual/en/function.mail.php

Regards,
Erwin Moller
>

MJ wrote:
>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';
?>
Jan 31 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.