B4X Requires Chilkat v11.0.0+
B4X
Gmail SMTP: Authenticate with an App Password on Port 465
See more GMail SMTP/IMAP/POP Examples
Test app-password authentication over implicit TLS on port 465. This example authenticates and closes the connection without sending a message; its title now reflects that behavior.
Use an account-specific app password generated after enabling 2-Step Verification, loaded from protected configuration. A normal Google password will not work. App passwords may be unavailable under account or Workspace policy; OAuth2 is preferred. Changing the Google account password revokes app passwords. The obsolete less-secure-apps switch is not a setup option. Google app-password requirements.
See the Gmail SMTP, IMAP, and POP3 guide for current authentication choices and Gmail-specific examples.
Chilkat B4X Downloads
Dim success As Boolean = False
' Assumes Chilkat is unlocked. See Global Unlock Sample.
Dim mailbox As String = "user@example.com"
Dim mailman As ChilkatMailMan
mailman.Initialize("mailman")
mailman.SmtpHost = "smtp.gmail.com"
mailman.SmtpPort = 465
mailman.SmtpSsl = True
mailman.StartTLS = False
mailman.RequireSslCertVerify = True
mailman.SmtpUsername = mailbox
mailman.SmtpPassword = "YOUR_16_CHARACTER_APP_PASSWORD"
success = mailman.SmtpConnect
If success <> True Then
Log("Could not establish the Gmail SMTP TLS connection.")
Return
End If
success = mailman.SmtpAuthenticate
mailman.CloseSmtpConnection
If success <> True Then
Log("SMTP authentication failed. Check the app password and account policy.")
Return
End If
Log("SMTP authentication succeeded; no message was sent.")