Gmail SMTP v1.1.7插件OAuth认证失败求助:发送测试邮件报错334
Hey there, let’s work through that XOAUTH2 auth failure (334 error) you’re facing with the Gmail SMTP v1.1.7 plugin. You’ve already got the OAuth keys sorted and the plugin connected, so let’s dive into the most likely fixes:
Double-check your OAuth scope permissions
Gmail’s SMTP requires specific scopes to allow sending emails. Make sure your OAuth client in the Google Developer Console has either the fullhttps://mail.google.com/scope (most reliable for SMTP) or at minimumhttps://www.googleapis.com/auth/gmail.send. A too-restrictive scope is a common reason the server rejects the auth request with a 334 error.Validate your OAuth token’s validity and formatting
A 334 error often means the server is waiting for a properly formatted auth credential. First, confirm your refresh token isn’t expired—try regenerating it in the developer console and updating the plugin with the new token. Also, ensure the plugin is constructing the XOAUTH2 string correctly: it should be base64-encoded and follow this format:user=your_email@gmail.com\001auth=Bearer your_oauth_token\001\001Any mistake in this string structure will trigger the 334 failure.
Adjust your SSL verification settings (with caution)
From your server logs, I see you’ve disabled SSL peer verification (verify_peer => false, etc.). While this might seem like a quick fix, Gmail’s SMTP server enforces strict SSL/TLS standards. Try re-enabling SSL verification by settingverify_peerandverify_peer_nametotrue, and removing theallow_self_signedoption. Disabling verification can cause hidden handshake issues that indirectly break the auth flow.Review your Gmail account security settings
- If you have two-step verification enabled on your Gmail account, OAuth tokens won’t work—you’ll need to use an App Password instead (generate one in your Google Account’s Security settings).
- For G Suite (Google Workspace) accounts, check with your admin to ensure they haven’t restricted SMTP access or OAuth permissions for your account.
Your Error Context:
错误信息:Gmail SMTP, CLIENT -> SERVER: AUTH XOAUTH2, SMTP ERROR: AUTH command failed: 334
服务器日志片段:
2018-04-15 00:46:32 Connection: opening to smtp.gmail.com:587, timeout=300, options=array ( 'ssl' => array ( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true, ), ) 2018-04-15 00:46:33 Connection: opened
内容的提问来源于stack exchange,提问作者Matas Vaitkevicius

