PHP Pear Mail导致浏览器重置连接

时间:2013-10-10 15:31:32

标签: php email pear

我正在使用Pear Mail发送带有SMTP附件的电子邮件。它在所有浏览器中抛出“连接重置”错误。这是我的代码:

    require_once "Mail.php";
    require_once 'Mail/mime.php';

//      $text = 'Text version of email';
    $html = $email;
    $file = $path_to_pdf.$filename;
    $crlf = "\n";
    $hdrs = array(
              'From'    => 'support@ticktbox.com',
              'Subject' => 'Your Passes'
              );

    $mime = new Mail_mime(array('eol' => $crlf));

    //      $mime->setTXTBody($text);
    $mime->setHTMLBody($html);
    $mime->addAttachment($file, 'application/pdf');

    $host = "ssl://email-smtp.us-east-1.amazonaws.com";
    $port = "465";
    $username = "username";
    $password = "password";

    $body = $mime->get();
    $hdrs = $mime->headers($hdrs);

    $smtp = Mail::factory('smtp',
  array ('host' => $host,
    'port' => $port,
    'auth' => true,
    'username' => $username,
    'password' => $password));

    $mail = $smtp->send($user->email, $hdrs, $body);
    if (PEAR::isError($mail)) {
        echo($mail->getMessage());
    } else {
    //        echo("Message successfully sent!\n");
    }

我在所有浏览器中都遇到连接重置错误。关于为什么的任何想法?

0 个答案:

没有答案