1

我正在使用 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");
    }

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

4

0 回答 0