[英]Laravel Gmail: 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
[英]Cannot send email from Yii SwiftMail to GMail: Expected response code 250 but got code “535”
我得到這個錯誤代碼:
預期響應代碼 250,但得到代碼“535”,消息“535-5.7.8 用戶名和密碼不被接受。了解更多信息,請訪問 535 5.7.8 https://support.google.com/mail/answer/14257
但是,我使用的是 TLS,所以怎么可能更安全?!
還有一些其他問題,但它們不是針對 Yii 的。
一些代碼:
Yii::$app->mailer->setTransport([
'class' => 'Swift_SmtpTransport',
'host' => BestSales::getConfigValue('smtp.host'),
'username' => BestSales::getConfigValue('smtp.username'),
'password' => BestSales::decrypt(BestSales::getConfigValue('smtp.password.encrypted')),
'port' => BestSales::getConfigValue('smtp.port'),
'encryption' => BestSales::getConfigValue('smtp.encryption'), // 'tls', 'ssl'
]);
價值觀:
[
'smtp.host' => 'smtp.gmail.com',
'smtp.username' => 'contact@xxxxxxxxxx.com',
'smtp.password.encrypted' => 'xxxxxxxxxxx',
'smtp.port' => '587',
'smtp.encryption' => 'tls',
]
我登錄 Gmail 后發現了這條消息:
登錄嘗試被阻止
您好 BestSales,有人剛剛嘗試從不符合現代安全標准的應用程序登錄您的 Google 帳戶 contact@xxxxxxxx.com。 詳細信息:2016 年 5 月 17 日,星期二 23:27(東部夏令時間)美國弗吉尼亞州阿什本* 我們強烈建議您使用 Gmail 等安全應用訪問您的帳戶。 Google 開發的所有應用都符合這些安全標准。 另一方面,使用安全性較低的應用程序可能會使您的帳戶容易受到攻擊。 了解更多。Google 停止了這次登錄嘗試,但您應該檢查一下您最近使用過的設備
Yii 文檔說 'tls' 是一個選項。 http://www.yiiframework.com/doc-2.0/yii-swiftmailer-mailer.html
是的,我驗證了解密的值是正確的密碼。 我已經訪問過https://accounts.google.com/DisplayUnlockCaptcha 。 我無法打開 2-factor,因為我不擁有該帳戶並且它需要一個電話號碼。 我現在無法打開“允許不安全訪問”,因為它是客戶的帳戶,但我已經問過了。 (不過,我寧願不允許不安全的訪問。)
1. Enable the 2-step verification
2. Create App Passwdord to be use by your system HERE and use it
3. Now go to .env file and make these changes
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=youremail@gmail.com
MAIL_PASSWORD=password generated from app password
MAIL_ENCRYPTION=tls
This worked fine on mine.
For 2-step verification
https://www.google.com/landing/2step/
For App Password
https://security.google.com/settings/security/apppasswords
嘿,經過幾個小時的研究,給你一些提示:
1 - 在 Gmail 上啟用安全性較低的應用程序訪問
2 - 訪問此鏈接: https : //www.google.com/accounts/DisplayUnlockCaptcha
3 - 在 config/web.php 添加這些參數:
'encryption' => 'tls',
'streamOptions' => [
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
],
試試
'smtp.port' => '465',
'smtp.encryption' => 'ssl',
您必須登錄您的 Gmail 帳戶並進入安全設置並通知他們您正在嘗試訪問您的帳戶。 他們在上面放了一個塊,因為它看起來很可疑。
轉到此鏈接並重試。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.