Official Content

This article describes some specific considerations you need to take into account when sending or receiving emails using a Google Account (Gmail, Google for Business, or any edition).

Authentication and Authorization

As of May 30th, 2022, Google will no longer provide access to less secure apps (here is the announcement). That is to say, you cannot authenticate by just assigning in the Username and Password properties of the SMTPSession or POP3Session the email and password of the Google Account.

One solution is to use, instead of the Google Account password, an Application Specific Password.

Using application-specific Password

App Passwords can only be used with accounts that have 2-Step Verification turned on.

Sample code snippet setting properties to create a Pop3 session: 

&Pop3Session.Host = 'pop.gmail.com'
&Pop3Session.Port = 995
&Pop3Session.Timeout = 30
&Pop3Session.UserName = 'myemail@gmail.com'
&Pop3Session.Password = 'abcdabcdabcdabcd' // 16-digit App password given by Google
&Pop3Session.Secure=1

Steps to get an App Password:

  1. Turn on 2-Step Verification in the Google Account
  2. Create an app password
  3. Use that password in the application (assigning it to the corresponding Password property).

Note: The above is valid for all versions of GeneXus.

Using OAuth2

OAuth2 is the recommended authentication method by Google and is supported in GeneXus since version GeneXus 17 Upgrade 9. To use OAuth2, you must use the OAuth Module and perform additional steps.

To send and receive emails with OAuth2, the latest email libraries must be used:

  • In .NET, this means using MailKit.
  • In Java, this means using JakartaMail.

These libraries are not enabled by default. You need to manually configure your Knowledge Base to activate them, as explained in OAuth Module.

See Also

SAC 50932 - OAUTH support for sending and receiving mails
SMTPSession Data Type
POP3Session Data Type

 


Last update: June 2025 | © GeneXus. All rights reserved. GeneXus Powered by Globant