The following code worked fine until recently using port 25. Now it tells me it can't authenticate. If I use the recommended port 465 it doesn't give me an error but it eventually times out. Anyone have any code that works with GMAIL for SMTP mail? I've enabled the POP mail setting on the email account. Other suggestions? Thanks.
Jim
rqm_user = '....@gmail.com'
rqm_pw_word = '........'
whoto = '...............com'
whofrom = '....@gmail.com'
msg = "HELLO WORLD"
subj = "Hello World"
port = 465
rqm_smtpserver = "smtp.gmail.com"
IntControl(73, 2, @TRUE,"",0)
ObjectClrOption("use","System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
_TRUE = ObjectType( "BOOL", @TRUE )
_FALSE = ObjectType( "BOOL", @FALSE )
NetworkCredential = ObjectClrNew( 'System.Net.NetworkCredential', rqm_user, rqm_pw_word)
MailAddress_From = ObjectClrNew( 'System.Net.Mail.MailAddress', whofrom )
MailAddress_To = ObjectClrNew( 'System.Net.Mail.MailAddress', StrTrim(ItemExtract(1,whoto,"|")))
MailMessage = ObjectClrNew( 'System.Net.Mail.MailMessage', MailAddress_From, MailAddress_To )
whoto2 = ""
If ItemCount(whoto,"|") > 1 Then
For mailcnt = 2 to ItemCount(whoto,"|")
whoto2 = StrTrim(ItemExtract(mailcnt,whoto,"|"))
If ItemCount(whoto2,"@") > 1 Then MailMessage.To.Add(whoto2)
Next
EndIf
MailMessage.IsBodyHtml = _TRUE
MailMessage.Subject = subj
MailMessage.Body = msg
SmtpClient = ObjectClrNew('System.Net.Mail.SmtpClient')
SmtpClient.Host = rqm_smtpserver
If StrTrim(port) == "" Then port = 25
port = port+0
SmtpClient.Port = port
SmtpClient.Credentials = NetworkCredential ; Authentication
SmtpClient.EnableSsl = _TRUE ; Use SSL
rc = "Failed"
message("HI","")
SmtpClient.Send(MailMessage) ; Send
Return
:WBERRORHANDLER
message("Error","There seems to be a problem...")
Exit
Return
Try port 587.
I get the same message I get with port 25 and bad login info. I've also turned off my [software] firewall but get the same results.
Jim
"COM/CLR Exception:
System
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at"
Then you haven't modified your gmail account settings to allow less secure apps to access your gmail account. Google is becoming more and more like the old Microsoft.
Embrace, extend, and extinguish...
http://en.wikipedia.org/wiki/Embrace,_extend_and_extinguish (http://en.wikipedia.org/wiki/Embrace,_extend_and_extinguish)
You beat me to it. Finally found that little caveat in the Help section. Once I enable that option and use port 587 it works. Thanks.
Jim
Quote from: td on December 09, 2014, 07:18:42 AM
Then you haven't modified your gmail account settings to allow less secure apps to access your gmail account. Google is becoming more and more like the old Microsoft.