SmtpClient() does not connect to gmail.

Xbase++ 2.0 Build 554 or later
Message
Author
User avatar
PedroAlex
Posts: 234
Joined: Tue Feb 09, 2010 3:06 am

SmtpClient() does not connect to gmail.

#1 Post by PedroAlex »

Hello!

SMTPClient():new( "smtp.gmail.com", 465,, , 3) fail to conect the gmail server.
Looks like google changed the security settings for accessing email servers.
Does anyone know if there is a solution to work around this problem?

xBase 2.0.1176
Pedro Alexandre

User avatar
rdonnay
Site Admin
Posts: 4775
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: SmtpClient() does not connect to gmail.

#2 Post by rdonnay »

This is what I have been using for many years and it still works.

cSMTPServer := 'smtp.gmail.com'
cPort := "465"
oSmtp := SMTPClient():new( Alltrim(cSMTPServer), Val(cPort),, oLogWriter, 2 )
The eXpress train is coming - and it has more cars.

Piotr D
Posts: 131
Joined: Mon Jul 28, 2014 1:26 am
Location: Poznań, Poland

Re: SmtpClient() does not connect to gmail.

#3 Post by Piotr D »

Hi Pedro,
for gmail try to use port 587.

Piotr

User avatar
PedroAlex
Posts: 234
Joined: Tue Feb 09, 2010 3:06 am

Re: SmtpClient() does not connect to gmail.

#4 Post by PedroAlex »

Roger and Poitr,

SmtpClient doesn't work anymore for me.
something happened that all customers with gmail are reporting the same problem.

I made a small program to test and reproduce the situation.
Can you please test with your version of xbase and report the result
Teste_GMAIL.rar
(15.58 KiB) Downloaded 786 times
Pedro Alexandre

User avatar
rdonnay
Site Admin
Posts: 4775
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: SmtpClient() does not connect to gmail.

#5 Post by rdonnay »

I sent a gmail message to you using my authentication.
Everything was a success.

I must tell you that I have had a Gmail account for about 20 years, so I am grandfathered in.
I am guessing that it is a problem with your account, not with SMTPClient().
The eXpress train is coming - and it has more cars.

User avatar
PedroAlex
Posts: 234
Joined: Tue Feb 09, 2010 3:06 am

Re: SmtpClient() does not connect to gmail.

#6 Post by PedroAlex »

Hi Roger,
Thanks for answering,

I received your test emails.
but with my version of xbase it doesn't work with any gmail account.
I've been studying Alaska xbase developments and there have been a lot of changes to SmtClient() and MimeMessage().
I suspect my version 2.0.1176 has issues that have been resolved in the newer versions!
Turns out my subscription is expired.
Can you confirm your version of Alaska?

Many Thanks!

Note : Can anyone else who has an equal or lower version inform the test result?
Pedro Alexandre

User avatar
rdonnay
Site Admin
Posts: 4775
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: SmtpClient() does not connect to gmail.

#7 Post by rdonnay »

Xbase++ (R) Compiler 2.00.1542 Dec 10 2021
The eXpress train is coming - and it has more cars.

Diego Euri Almanzar
Posts: 174
Joined: Thu Nov 05, 2020 10:51 am
Location: DOMINICAN REPUBLIC

Re: SmtpClient() does not connect to gmail.

#8 Post by Diego Euri Almanzar »

I had a lot of trouble creating a SMPT client object using the GMAIL server.

I was able to overcome it by enabling the option for "UNSAFE APPS" in the settings
of the GMAIL account.

To enable it, it is recommended to perform the following steps:



1.- Click on the image of your Gmail account.



2.- Then click on "Google Account"



3.- Click on “Security”



4.- Go to the section “Access of insecure applications” and click on “Activate access”



5.- Finally activate "Allow access to insecure applications"




The version of Alaska that I use is 2.00.1503


Best regards

User avatar
PedroAlex
Posts: 234
Joined: Tue Feb 09, 2010 3:06 am

Re: SmtpClient() does not connect to gmail.

#9 Post by PedroAlex »

Diego,

5.- Finally activate "Allow access to insecure applications"

If I figure out this switch, send gmail, works fine!

but this feature expires on 31 May 2022.!

Do you know any more solution?
Pedro Alexandre

User avatar
PedroAlex
Posts: 234
Joined: Tue Feb 09, 2010 3:06 am

Re: SmtpClient() does not connect to gmail.

#10 Post by PedroAlex »

So!

* Starting May 30, 2022, Google will no longer support the use of third-party apps or devices
* which ask you to sign in to your Google Account using only your username and password.

* Instead of authenticating with your GMail username/password, a GMail user can create an App Password
* and then login using their username/app_password. It's literally the same, except it allows a GMail
* account owner to isolate passwords to specific applications.

* The Gmail account owner would first need to make sure she has 2-Step Verification setup for her account.
* Note: The 2FA verification is not a factor when authenticating with an app password. The 2FA is required
* to setup app passwords in the Google account console. See https://support.google.com/accounts/answer/185833

* After the GMail account owner has setup his app password, he simply uses the app password instead of his GMail account password.

It was simply for this reason that smtpclient did not work...
Pedro Alexandre

Post Reply