This post shows how to use the Pega 7 Email Wizard for setting up a new Pega 7 Google Gmail integration so that a Google Mail (gmail.com) account can be used in a Pega 7 application for sending and receiving emails.
- Pega Setup Used in this Example
- Enable SMTP for the Google Mail Account
- Create Pega 7 Email Account Rule with the Email Wizard
- Test the Connection to the Google Mail Account
- Send Automatic Email Notifications in Pega 7 with the Send Email Smart Shape
1 Pega Setup Used in this Example
For this post, Pega 7.1.6 was used with the following Pega setup:
- Pega 7.1.6 is installed as a Personal Virtual Server (PVS) utilizing the VMWare Player.
- For details, see the Downloading the Exercise System sections of the SAE I (7.1) and SSA (7.1) courses provided by Pega Academy.
- Windows 7 was used as the host operating system.
- The virtual machine’s network adapter is configured to used a bridged network connection as shown below.
- Note: Make sure that the Pega PVS instance is able to connect to the Internet. If the Internet access is not setup properly, the connection to the Google mail server will fail.
- As an alternative, see the below post on how to run the Pega 7 Exercise System on Tomcat 9 and PostgreSQL – without the need for a virtual machine:
2 Enable SMTP for the Google Mail Account
Log into the Google Mail account and click on the cog wheel icon in the upper right hand corner to access the account settings.
- Click on the Forwarding and POP/IMAP tab in the settings screen
- Under IMAP Access, make sure to turn on Enable IMAP.
- For more information on IMAP, refer to this article on Wikipedia.
3 Create Pega 7 Email Account Rule with the Email Wizard
- Before the Send Email smart shape can be used in a flow to automatically send emails, it is necessary to setup a new email account rule.
- In the Designer Studio, click on Designer Studio >Integration > Email > Email Wizard.
(1) Enter Email Information
- On the first screen of the Email Wizard (also known as Email Accelerator), select
Configure an email accountin the drop-down control for What would you like to do?
- In the second drop-down control for Which work pool will be associated with this EmailAccount?, select the applicable work pool. Here it is
- All case types that belong to the
ABC-Insurance-Workwork pool will use this email account when a Send Email smart shape is used in a flow.
- Do not check the check box next to Would you like to use the Default EmailAccount key?
- Click on the Next button to continue.
(2a) Outbound Email – Enter Account Info
- On the next screen, click on the button Select Email Provider to let the wizard pre-fill certain parameters for some of the most common email providers.
- In this case, the wizard is used to configure a Google Mail account, so select
- In the From field of the Sender section, enter the email address for sending emails (outbound).
- In this case, it is a Gmail email account called
- The same email address can be used for receiving emails in Pega (inbound).
- Make sure the other parameters in the Sender section are set as follows:
smtp.gmail.com(see Simple Mail Transfer Protocol)
- In the Receiver section set the parameters as follows:
IMAP(see Internet Message Access Protocol)
- Click on the Set Password button in the Sender section to set the password for the sender email account. This is the password for accessing the specified Gmail account.
- Click on the Set Password button in the Receiver section to set the password for the receiver email account. Again, this is the password for accessing the specified Gmail account.
- After setting the sender and receiver passwords, click on Next to continue. The subsequent screen shows a summary of the email account settings, click on Next to continue.
- A confirmation screen will show a message indicating that the Email Wizard has completed setting up the email account.
- Click on Done to close the Email Wizard.
4 Test the Connection to the Google Mail Account
- In the Designer Studio, navigate to Integration > Email > Email Accounts to view a list of available email accounts.
- The previously configured Google Mail account should now appear in the list.
- Click on the new Google Mail email account to open the Email Account rule.
- This will open a form similar to the earlier configuration form and allows to test the connection.
- Click on the Test Connectivity button in the Sender section. PRPC will attempt to connect to the specified Google Mail account and it will show the result in a new window.
- At this point, the connection may fail and the result may look like the screen shot below, showing a message saying that the authentication credentials for this Email Account are incorrect.
- This is actually not the case. The reason for this error message is a default security setting of the Google Mail account. It prevents clients deemed not secure by Google from connecting.
- The reason for this could be the fact that PRPC uses a self-signed SSL certificate. In a production environment, a SSL certificate signed by a certificate authority should be used.
- The Google Mail account which was configured with the Email Wizard should have received a message from Google saying that a Sign-in attemtp was prevented.
- Login to the Google Mail account and navigate to Sign-in & security and scroll down to a section called Allow less secure apps and switch the setting from OFF to ON.
- Repeat the connection test by clicking on the Test Connection button in the Sender section.
- The connection to the Google Mail account should now succeed with a confirmation message: Connected successfully to email server. Disconnected successfully from email server.
- The connection test for the Receiver part of the configuration should succeed as well.
- The result should look like the screen shot below.
- The Email rule is now ready to be used in a Send Email smart shape in a flow rule.
5 Send Automatic Email Notifications in Pega 7 with Send Email Smart Shape
- In this example, a section is used to present a form to collect customer data. The customer’s email is entered by the operator.
- Once the form is submitted, PRPC will automatically send a confirmation email to the customer, using the sender email account
email@example.com in step 2.
- In the related flow, a Send Email smart shape is used to automatically send the confirmation email.
- Right click on the Send Email smart shape to configure it.
Email addressfor the Send to option.
- For Message, select
- The To email address is a property of type text, here it is set to
- A new correspondence template can be created using the Application Explorer.
- Under the case type rule, right click on Process > +Create > Correspondence.
- The correspondence rule for this example is shown in the screen shot below.
- Properties and other dynamic content can easily be inserted into the correspondence body.
- When a new case is created, the confirmation email will be sent automatically by PRPC once the Collect Customer Information form has been submitted by the operator.
- The customer will receive an email that looks like this:
- The customer’s first name has been inserted dynamically and the sender name EMail System, configured in step 2, is shown.