PHP邮件无法连接

时间:2018-04-04 18:05:28

标签: php email

我正在尝试使用php从服务器发送电子邮件 这是代码

$from = "Sandra Sender <dev@mywebsite.space>";
$to = "Ramona Recipient <myemail3@gmail.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "webmail.mywebsite.space";
$username = "dev@mywebsite.space";
$password = "JjLvUZIoeeI4";
$headers = array ('From' => $from,
'To' => $to,
 'Subject' => $subject);
$smtp = Mail::factory('smtp',
 array ('host' => $host,
  'auth' => true,
  'username' => $username,
  'password' => $password));
  $mail = $smtp->send($to, $headers, $body);
  if (PEAR::isError($mail)) {
   echo("<p>" . $mail->getMessage() . "</p>");
  } else {
  echo("<p>Message successfully sent!</p>");
  }

但是收到此错误

  

无法连接到webmail。@ mywebsite.space:25 [SMTP:无法连接套接字:连接被拒绝(代码:-1,响应:)]

我在这里错过了什么吗?

的iptables

    To                         Action      From
  --                         ------      ----
  80,443/tcp (Apache Full)   ALLOW IN    Anywhere
  22                         ALLOW IN    Anywhere
  22/tcp (OpenSSH)           ALLOW IN    Anywhere
  25                         ALLOW IN    Anywhere
  25/tcp                     ALLOW IN    Anywhere
  80,443/tcp (Apache Full (v6)) ALLOW IN    Anywhere (v6)
  22 (v6)                    ALLOW IN    Anywhere (v6)
  22/tcp (OpenSSH (v6))      ALLOW IN    Anywhere (v6)
  25 (v6)                    ALLOW IN    Anywhere (v6)
  25/tcp (v6)                ALLOW IN    Anywhere (v6)

0 个答案:

没有答案