Unsecured login error when sending email (Gmail) using AutoHotkey

-1

Is there a better login method in AutoHotkey to do this? Or perhaps a way to allow unsecured logins to Google? I have enabled less secure apps on the Google account settings.

AutoHotkey error:

This message could not be sent to SMTP server. The transport error codwe was 0x80040217. The server response was not available.

Gmail response (some info redacted):

Sign-in attempt prevented

Hi [redacted],

Someone just tried to sign in to your Google Account [redacted]@gmail.com from an app that doesn't meet modern security standards.

...

AutoHotkey script (some info redacted):

pmsg                         := ComObjCreate("CDO.Message")
pmsg.From                    := """John Doe"" <John.Doe@gmail.com>"
pmsg.To                      := "Jane.Doe@gmail.com, Joe.Schmo@gmx.com"
pmsg.BCC                     := ""                   ; Blind Carbon Copy, Invisible for all, same syntax as CC
pmsg.CC                      := "redacted@gmail.com" ; Somebody@somewhere.com, Other-somebody@somewhere.com
pmsg.Subject                 := "See below"
;pmsg.TextBody               := ""
pmsg.HtmlBody                := "<html><head><title>Hello</title></head><body><table border='1'><tr><td>row 1, cell 1</td><td>row 1, cell 2</td></tr><tr><td>row 2, cell 1</td><td>row 2, cell 2</td></tr></table> </body></html>"
;sAttach                     := ""                   ; can add multiple attachments, the delimiter is |
fields                       := Object()
fields.smtpserver            := "smtp.gmail.com"     ; specify your SMTP server
fields.smtpserverport        := 465                  ; 25
fields.smtpusessl            := True                 ; False
fields.sendusing             := 2                    ; cdoSendUsingPort
fields.smtpauthenticate      := 1                    ; cdoBasic
fields.sendusername          := "redacted@gmail.com"
fields.sendpassword          := "redacted"
fields.smtpconnectiontimeout := 60
schema                       := "http://schemas.microsoft.com/cdo/configuration/"
pfld                         := pmsg.Configuration.Fields

For field,value in fields
    pfld.Item(schema . field) := value
pfld.Update()

Loop, Parse, sAttach, |, %A_Space%%A_Tab%
    pmsg.AddAttachment(A_LoopField)
pmsg.Send()

return
email
gmail
autohotkey
google-login
asked on Stack Overflow Jan 15, 2016 by GJH105775 • edited Jun 20, 2020 by Community

1 Answer

0

Hmm, maybe you need the quotes around the formed schema-field:

    pfld.Item("""" . schema . field . """")       := value

Or try '"' to get the quotes.

Also, try port 25 and/or username w/o the @gmail part (but I think what you have is correct for gmail).

Hth,

answered on Stack Overflow Jan 15, 2016 by PGilm • edited Jan 15, 2016 by PGilm

User contributions licensed under CC BY-SA 3.0