PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → WB20: gmail doesn't send (anymore)
WB20: gmail doesn't send (anymore)
Iniciado por guest, 29,abr. 2016 13:22 - 3 respuestas
Publicado el 29,abril 2016 - 13:22
Hello,

I have a procedure to send email with a google account and used the example from webdev help. But it doesn't work.

The message i recieve is:

The last response of SMTP server is:
<534-5.7.14 Please log in via your web browser and
534-5.7.14 then try again.

The login and password are okay.

The code is:

PROCEDURE SendEmail(sName is string, spar_RecipientEmail is string, spar_Subject is string,...
spar_Body is string, spar_SenderEmail is string, spar_Attachment is string, npar_NbAttach is numeric)

sMessage is string
sEMailOptions is string
nEmailOptions is int

sSenderEmail is string =NoSpace(spar_SenderEmail)
sRecipientEmail is string =NoSpace(spar_RecipientEmail)
sSubject is string =spar_Subject
sBody is string =sName+":="+CR+spar_Body

EmailSetTimeOut(10)
// Use a secured SMTP server with authentication
IF gbEmail_SMPT_SSL THEN
sEMailOptions = "emailOptionDefault"
nEmailOptions = emailOptionDefault
gnEmail_SMTP_Port = 465

ELSE
sEMailOptions = "emailOptionSecuredTLS"
nEmailOptions = emailOptionSecuredTLS
gnEmail_SMTP_Port = 587
END
//For this example i will show the variables:
sName = "Aad Mess"
gsEmail_no_reply = "ahjmess@gmail.com"
gsEmail_SMTP_Server = "smtp.gmail.com"
gnEmail_SMTP_Port = 587
spar_RecipientEmail = "ahjmess@gmail.com"
spar_Subject = "Test"
spar_Body = "Test"
spar_SenderEmail ="ahjmess@gmail.com"
spar_Attachment = ""
npar_NbAttach = 1
//gsEmail_password = ":-)"

//Open the Session
IF NOT EmailStartSMTPSession(gsEmail_no_reply,gsEmail_password,gsEmail_SMTP_Server,gnEmail_SMTP_Port,False,nEmailOptions) THEN
sMessage = "ERROR ( "+ErrorInfo()+" ). In case of a time-out, check the parameters of the firewall on the port used ( "+gnEmail_SMTP_Port+" )."
//Error(sMessage)
GloLogging("ERROR",sMessage)
GOTO RESULT_FALSE
END

// Initializes the components of the email
Email.Sender = sSenderEmail // The sender
//Trace(spar_SenderEmail, spar_RecipientEmail) //for testing
Email.SenderAddress=sSenderEmail
Email.Recipient[1] = sRecipientEmail // The recipient
Email.NbRecipient = 1 // The number of recipients
Email.Subject = sSubject // The subject
Email.Message = HTMLToText(sBody) // The body of the message
Email.HTML = sBody
Email.NbAttach = npar_NbAttach // The number of attachments
Email.Attach = spar_Attachment

IF NOT EmailSendMessage(gsEmail_no_reply) THEN
sMessage = "Cannot open connection ( "+ErrorInfo()+" ). In case of a time-out, check the parameters of the firewall on the port used ( "+gnEmail_SMTP_Port+" )."
//Error(sMessage)
GloLogging("ERROR",sMessage)
GOTO RESULT_FALSE
END

EmailCloseSession(gsEmail_no_reply)
RESULT True
Publicado el 29,abril 2016 - 16:15
Hi

and did you do what the error message says (ie login via your web browser to authorize the access via pop/smtp)?
Because that problem looks like a security measure from gmail

Best regards
Publicado el 06,mayo 2016 - 14:29
Just in case ...

Check whether you can send an e-mail from Outlook or any other application that uses the SMTP protocol, using the same account as in the WD. Gmail does not allow POP and SMTP protocols if they are not explicitly enabled in the settings of a user account.
It must also be enabled (do not know the exact name) "access using less secure apps"
Publicado el 06,mayo 2016 - 16:51
Fabrice is right. You likely need to make sure the gmail account is set up to "allow access to less secure applications"