You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Yii2 SwiftMailer发送邮件失败:SMTP 535认证错误求助

Troubleshooting Yii SMTP 535 Error with Yahoo Mail

Let's work through your issue step by step—here's what you need to check and fix:

The error message references Google's support page, but that's just a generic hint many SMTP providers use when rejecting credentials. This doesn't mean your app is still connecting to Google's SMTP server; it's just part of Yahoo's standard error response template.

2. Verify your Yahoo SMTP configuration & account settings

Even though you enabled less secure apps and tried an app password, double-check these critical details:

  • App Password requirements: Yahoo requires you to have two-step verification (2SV) enabled on your account before you can generate a valid app password. If you didn't turn on 2SV first, the app password won't work at all.
  • Correct app password usage: When generating an app password for your Yii app, make sure you copy the full, unmodified string (no spaces, no extra characters) into your password config field.
  • Double-check SMTP parameters: Your current config looks right on paper, but confirm:
    • host is exactly smtp.mail.yahoo.com
    • port is 587 with encryption set to tls
    • username is your full Yahoo email address (you have this correct, but typos are easy to miss!)

3. Rule out Yii application caching (not Apache)

Apache does not cache SMTP credentials—this is a common misconception. However, Yii might be caching your old Google SMTP configuration if you have config caching enabled. To fix this:

  • Flush Yii's application cache using the console command:
    ./yii cache/flush-all
    
  • Alternatively, manually delete the cache files in your app's runtime/cache directory to force Yii to load the new config.

4. Validate your SMTP connection outside of Yii

To confirm the issue isn't with your code, test the Yahoo SMTP connection directly using a tool like Swaks or Telnet:

  • Using Telnet:
    telnet smtp.mail.yahoo.com 587
    EHLO localhost
    AUTH LOGIN
    # Enter your base64-encoded email address
    # Enter your base64-encoded app password
    

If this fails, the problem is definitely with your Yahoo account settings, not your Yii code. If it works, then you know the issue is in how Yii is loading or using the config.

5. Final checks

  • Ensure you've logged into your Yahoo account via the web recently to confirm there are no pending security alerts (Yahoo sometimes blocks new app connections until you verify the login is legitimate).
  • If you're using a regional Yahoo domain (like yahoo.co.uk), confirm the SMTP host matches (it should still be smtp.mail.yahoo.com, but double-check for regional variations).

内容的提问来源于stack exchange,提问作者Valik Tralik

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:11:37