第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

SwiftMailer 測試用戶名和密碼

SwiftMailer 測試用戶名和密碼

PHP
寶慕林4294392 2021-11-26 17:46:57
我真的不知道這是否是關(guān)于SwiftMailer或mailtrap.io但問題是當(dāng)我嘗試建立到所述服務(wù)的 SMTP 連接時 ( mailtrap.io) 我從來沒有收到任何錯誤,即使我不使用任何用戶名或密碼。不使用任何用戶名或密碼時,我不應(yīng)該收到任何身份驗證錯誤嗎?還是我這樣做是錯誤的?這是我在將其存儲到.env文件中之前用于測試是否可以建立動態(tài)連接的方法。/** * E-mail configuration * * @param Request $request * @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse */public function postEmailConfiguration(Request $request){    # Try connecting to the SMTP    try {        $encryption = $request->input('encryption');        if ($encryption == 'null') {            $encryption = NULL;        }        $transport = new Swift_SmtpTransport($request->input('host'), $request->input('port'), $encryption);        $transport->setUsername($request->input('username'));        $transport->setPassword($request->input('password'));        $mailer = new Swift_Mailer($transport);        $mailer->getTransport()->start();        # Update .env file        $this->setEnvironmentValues([            'MAIL_HOST' => $request->input('host'),            'MAIL_PORT' => $request->input('port'),            'MAIL_USERNAME' => $request->input('username'),            'MAIL_PASSWORD' => $request->input('password'),            'MAIL_ENCRYPTION' => $request->input('encryption')        ]);        return redirect()->back()->with('success', 'Connection to SMTP establised and saved!');    }    # Could not connect to SMTP    catch (Swift_TransportException $e) {        return redirect()->back()->with('error', 'Could not connect to SMTP server.<br>Error: ' . $e->getMessage());    }    # Could not connect to SMTP    catch (Exception $e) {        return redirect()->back()->with('error', 'Could not connect to SMTP server.<br>Error: ' . $e->getMessage());    }}
查看完整描述

1 回答

?
慕尼黑的夜晚無繁華

TA貢獻(xiàn)1864條經(jīng)驗 獲得超6個贊

我在 Symfony 4.4 上使用SwiftMailer 6測試了與 Gmail 的連接,下面的代碼(與您的類似)對我來說按預(yù)期工作。


因此,如果您想檢查是否在沒有消息發(fā)送的情況下建立了連接,請使用下一個代碼:


public function checkConnection()

{

    try {

        // Create the Transport

        $transport = (new \Swift_SmtpTransport(

            'smtp.gmail.com',

            '587',

            'tls'

        ))

            ->setUsername('your.username@gmail.com')

            ->setPassword('yourSuperPassword');

        // Create the Mailer using your created Transport

        $mailer = new \Swift_Mailer($transport);


        $mailer->getTransport()->start();


        return true;

    } catch (\Swift_TransportException $e) {

        return $e->getMessage();

    } catch (\Exception $e) {

        return $e->getMessage();

    }

}

否則,它會拋出異常:


Swift_TransportException:

Failed to authenticate on SMTP server with username "your.username@gmail.com" using 3 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at

535 5.7.8  https://support.google.com/mail/?p=BadCredentials z7sm3020898ljj.98 - gsmtp". 

Authenticator PLAIN returned Expected response code 235 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at

535 5.7.8  https://support.google.com/mail/?p=BadCredentials z7sm3020898ljj.98 - gsmtp". 

Authenticator XOAUTH2 returned Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at

535 5.7.8  https://support.google.com/mail/?p=BadCredentials z7sm3020898ljj.98 - gsmtp".


查看完整回答
反對 回復(fù) 2021-11-26
  • 1 回答
  • 0 關(guān)注
  • 254 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號