2016-05-27 19 views
1

私のYii2アプリケーションでは、私はswiftで電子メールを送信する連絡フォームを持っています。Yii2 smtpエラー500 5.5.1コマンドが認識されない

私はこのように自分のアプリケーションを構成した:

ものはweb.phpで構成されている:

'mailer' => [ 
     'class' => 'yii\swiftmailer\Mailer', 
     // send all mails to a file by default. You have to set 
     // 'useFileTransport' to false and configure a transport 
     // for the mailer to send real emails 
     'useFileTransport' => false, 
     'transport' => [ 
      'class' => 'Swift_SmtpTransport', 
      'host' => 'authsmtp.myhost.com', 
      'username' => 'username', 
      'password' => '************', 
      'port' => '25', 
      'encryption' => 'tls', 
     ], 
    ], 

、これは私がメールを送信する私のコントローラの一部です:

Expected response code 220 but got code "500", with message "500 5.5.1 command unrecognized"

01:
if($contact->load($post) && $contact->validate()) 
    { 
      Yii::$app->mailer->compose('request',['contact' => $contact ]) 
        ->setFrom('[email protected]') 
        ->setTo('[email protected]') 
        ->setSubject('This is a test email') 
        ->send(); 

      return $this->redirect(['login/index']); 
    } 

は、私はこのエラーでSwift_TransportExceptionを受け取ります

swiftによって生成されたエラーに関する詳細情報を取得する方法はありますか? このメッセージはあまりにも一般的です。ログ使用yii\swiftmailer\Loggerのためにすべてのヘルプ

+0

SSL/TLSを使用するSMTPは、通常、ポート465または587を使用します。サーバーはポート25でtlsを使用するように設定されていますか? – topher

+0

こんにちは、あなたの返事をありがとう。プロバイダの指示によると、ドメインのsmptをポート25に設定するとします。 – giovaZ

+0

それから '暗号化せずに送信してみてください。 – topher

答えて

2

を事前に ありがとう:

Logger is a SwiftMailer plugin, which allows passing of the SwiftMailer internal logs to the Yii logging mechanism. Each native SwiftMailer log message will be converted into Yii 'info' log entry.

SMTPポートは465または587 SSL/TLSで、かつ25なしです。

SMTP by default uses TCP port 25. The protocol for mail submission is the same, but uses port 587. SMTP connections secured by SSL, known as SMTPS, default to port 465 (nonstandard, but sometimes used for legacy reasons).

サーバーが明示的に暗号化を使用すべきではありませんSSL/TLSでポート25を使用するように設定されていない限り:Wikipedia page on SMTPから。

+0

また私は最初の質問の答えを見つけました。 yii2のswiftmailerにはlogger(yii \ swiftmailer \ Logger)というプラグインがあります。この方法で設定することができます:http://www.yiiframework.com/doc-2.0/yii-swiftmailer-logger.html – giovaZ

+0

ああ。私は最初の質問を見ていませんでした。あなたの提案を答えに加えました。 – topher

関連する問題