邮件没有通过smtp获取错误

时间:2014-12-30 04:23:16

标签: php mysql smtp

我无法使用smtp发送邮件。我收到以下错误

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

我的代码如下

<?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";
  } 
?>

我的错误如下。 无法连接到smtp.ample.co.in:25 [SMTP:无法连接套接字:权限被拒绝(代码:-1,响应:)]

0 个答案:

没有答案