lundi 29 décembre 2014

mail is not going through smtp getting the error


Vote count:

0




i am not able to send mail using smtp. I am getting the following error



Failed to connect to smtp.ample.co.in:25 [SMTP: Failed to connect socket: Permission denied (code: -1, response: )]


my code is as follows



<?php
require_once "Mail.php";


$from="test@example.com";
$to="test@example.com";
$subject="Mail Test";
$body = "This is a test!";
$host = "smtp.ample.co.in";
$username = "test@example.com";
$password = "test";

$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject,
'MIME-Version'=>'1.0',
'Content-type'=>'text/html;charset=iso-8859-1'
);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));


$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
$errormessage="<p>" . $mail->getMessage() . "</p>";
echo $errormessage;
echo " not sent";
} else {
$errormessage="<p>Email Sent</p>";
echo $errormessage;
echo "sent";
}
?>


my error is as follows. Failed to connect to smtp.ample.co.in:25 [SMTP: Failed to connect socket: Permission denied (code: -1, response: )]



asked 13 secs ago







mail is not going through smtp getting the error

Aucun commentaire:

Enregistrer un commentaire