0
votes

I want to send email via Gmail (using AutoIt) but I do not know how to enable TLS. My code returns an error (4):

#include <Inet.au3>
#include <MsgBoxConstants.au3>
#Include<file.au3>

Local $sSMTPServer  = "smtp.gmail.com";
Local $sFromName    = "Emeka";
Local $sFromAddress = "[email protected]";
Local $sToAddress   = "[email protected]";
Local $sSubject     = "AuToIT";
Local $aBody[1]     = "Test ";

Local $iResponse    = _INetSmtpMail($sSMTPServer, $sFromName, $sFromAddress,$sToAddress, $sSubject, $aBody)
Local $iErr         = @error

If $iResponse = 1 Then

    MsgBox($MB_SYSTEMMODAL, "Success!", "Mail sent")

Else

    MsgBox($MB_SYSTEMMODAL, "Error!", "Mail failed with error code " & $iErr)

EndIf

Why is my email not being sent?

1
In the function it is hard coded to connect to port 25, however this is not allowed by the google servers. You'l have to rewrite the _INetSmtpMail function slightly to include TLS, not entirely sure how though. - Matt
One solution given is to use a different method entirely, using COM objects. Here. - Matt
For reference, question asked on AutoIt Forums. - Matt

1 Answers

1
votes

https://www.digitalocean.com/community/tutorials/how-to-use-google-s-smtp-server

You need to check the google SMTP settings, I think. I once made a mail sender and got some stupid error that is easily fixed. Check link above.