Greetings,
I'm experimenting with the Net library in an attempt to send an email message using SMTP with gmail as the email server. The message is not being sent. My logs show a "False" coming from the "Success" event. No errors are reported from the Try / Catch statement in the coding.
I went to the gmail help page and made sure my gmail account was set up correctly which it was. I checked the settings they suggested and I think I have the coding match most of them. Here are the settings that they said to use.
It seems I'm missing the authentication settings in my code so I attempted to set the authentication method but I didn't see any sample code showing what the syntax should be when trying to set that setting.
I also don't know if gmail requires AUTH_CRAM_MD5, AUTH_LOGIN or AUTH_PLAIN.
All help will be appreciated since I don't know what's missing.
Thanks.
I'm experimenting with the Net library in an attempt to send an email message using SMTP with gmail as the email server. The message is not being sent. My logs show a "False" coming from the "Success" event. No errors are reported from the Try / Catch statement in the coding.
B4X:
email.Initialize("smtp.gmail.com", 587, "[email protected]", "MyPassword", "EmailClient")
Dim Body As String
Dim Subj As String
Dim EmailTo As String
Subj="Test Email."
Body= "Testing 123."
EmailTo="[email protected]"
Try
email.StartTLSMode = True
email.UseSSL = True
email.To.Add(EmailTo)
email.HtmlBody=True
email.Subject = Subj
email.Body = Body
email.Sender = "Emad"
email.Send
Catch
Log("SendEmail " & LastException)
End Try
Sub EmailClient_MessageSent(Success As Boolean)
Log(Success)
End Sub
I went to the gmail help page and made sure my gmail account was set up correctly which it was. I checked the settings they suggested and I think I have the coding match most of them. Here are the settings that they said to use.
Outgoing Mail (SMTP) Server | smtp.gmail.com Requires SSL: Yes Requires TLS: Yes (if available) Requires Authentication: Yes Port for SSL: 465 Port for TLS/STARTTLS: 58 |
It seems I'm missing the authentication settings in my code so I attempted to set the authentication method but I didn't see any sample code showing what the syntax should be when trying to set that setting.
I also don't know if gmail requires AUTH_CRAM_MD5, AUTH_LOGIN or AUTH_PLAIN.
All help will be appreciated since I don't know what's missing.
Thanks.