Using the SMTP Application to send emails in Integration Cloud

Summary

In this tutorial, we will create an integration that queries Salesforce accounts and creates opportunities in Marketo, and then sends an email containing the total number of records queried from Salesforce and inserted into Marketo.

Before you begin

A valid Gmail account as we will use the Gmail SMTP server to send emails.

Steps

1. Log in to Integration Cloud.
2. Click Projects > Select a Project> Applications > Predefined Applications > Simple Mail Transfer Protocol (SMTP).
3. Click Add New Account.
4. Configure the Gmail SMTP settings as shown below. For information on the SMTP Account Configuration fields, see the below table:
Field
Description
Host
Host name or IP address or the domain name of the SMTP server.
Port
SMTP port defined on the SMTP server. This is the number of the port on which the SMTP host listens.
User
Valid user name on the SMTP server. This is the user name used to connect with the mail server.
Password
Password of the SMTP user. This is the password to connect with the mail server.
From
The email address of the sender, that is, the person that is going to send the messages.
To
E-mail address of the receiver. If you specify multiple addresses, separate them with commas without any spaces.
Response Timeout
The number of milliseconds Integration Cloud waits for a response before canceling its attempt to connect to the SMTP server. In case the network is slow or the SMTP server processing takes longer than usual, increase this value.
Read Timeout
The number of milliseconds in which Integration Cloud must read a response message from the SMTP server.
Write Timeout
Socket write timeout value in milliseconds.
SSL configuration details
Transport Layer Security
Type of security protocol Integration Cloud uses when communicating with the SMTP server port. Set to:
  • none to use a non-secure mode when communicating with the port on the SMTP server. This is the default.
  • explicit to use explicit security when communicating with the port on the SMTP server. With explicit security, Integration Cloud establishes an un-encrypted connection to the email server, and then switches to the secure mode.
  • implicit to use implicit security when communicating with the port on the SMTP server. With implicit security, Integration Cloud always establishes an encrypted connection to the email server.
Truststore Alias
This is the alias for the truststore that contains the list of certificates that Integration Cloud uses to validate the trust relationship. Integration Cloud uses the default truststore if you do not specify a truststore alias. You can add a new truststore from this field.
Note: Users who have the Administer permission under Settings > Access Profiles > Administrative Permissions > Functional Controls > Advanced Security can add, edit, and delete truststores.
Note: You can specify the From and To addresses either at the Account level here or while executing the operation. If you provide them at both places, Integration Cloud will use the addresses provided by you when you execute the operation.
Further, as shown below, set the Transport Layer Security to Implicit to connect to SSL port 465. Integration Cloud internally sets the mail.smtp.ssl.enable property to true.
 
If you want to connect to Gmail SMTP server TLS Port (587), specify the mandatory account configuration fields. Also, as shown below, specify the Transport Layer Security as Explicit.
 
If Transport Layer Security is set as Explicit, Integration Cloud adds the mail.smtp.tls.required property as true by default while executing the operation. Also, Integration Cloud connects to the SMTP server and issues STARTTLS to change the unencrypted connection to an encrypted connection.
5. After you have provided the above account configuration values, click Test on the Account Configuration page as shown below to test the SMTP server configuration.
6. Click Send to send the test email to the recipient.
You can also click Test on the Operations page to test the SMTP server configuration.
 
 
 
7. After you click Test on the Operations page, add the input values as shown below, and then click Run. Note that you can add attachments only while creating an Integration.
 
 
 
 
 
 
 
 
 

8. Use the SMTP Application to create the Orchestrated Integration as shown below.

Do the following:
  • Add the QueryAccounts operation from Salesforce.
  • Add the createOpportunities operation from Marketo.
  • Map the queried Salesforce accounts to Marketo createOpportunities.
  • Add the sizeOfList service from the List category.
  • Map the queried Salesforce accounts to the sizeOfList service to get the total number of accounts queried.
  • Add the sendEmail operation from the SMTP Application. Refer the below table to see the input and output parameters of the sendEmail operation.
sendEmail operation
Sends emails to specified recipients. You can attach one or more files to the message.
Input Parameters
from
String Optional. E-mail address of the sender.
to
String Optional. E-mail address of the receiver. If you specify multiple addresses, separate them with commas.
subject
String Subject of the message.
body
String The content of the message.
cc:
String Optional. E-mail addresses of additional receivers. If you specify multiple addresses, separate them with commas.
bcc:
String Optional. E-mail addresses of additional receivers. If you specify multiple addresses, separate them with commas.
subjectCharSet:
String Optional. The character set used to encode the subject. Default: UTF-8.
bodyCharSet:
String Optional. The character set used to encode the email message. Default: UTF-8.
attachments
Document List Attachments to the email message.
 
Key
Description
 
contenttype
String Content type of the attachment. For example: application/pdf.
 
content
byte[ ], String, or java.io.InputStream Content of the attachment.
filename
String Name to assign to the attachment.
 
encoding
String Encoding of the attachment, for example, base64 or 7bit. If encoding is not specified, 7bit is used.
charset
String Character set encoding of the attachment. If charset is not specified, then UTF-8 encoding is used.
 
Output Parameters
 
status
String Final status of the operation.
 
Usage Notes
 
*You must define the from and to fields either in the Account Configuration section or while executing the operation.
*If you are using filename to attach a file to the message and the file is not a plain text file, you must set the contenttype and encoding.
 
 
9. Map input and output.
 
10. Click subject and set a value. Then click body.
 
11. Set a value for the body, that is, type the email body. Wrap the dynamic fields which are in the pipeline with % and click Perform pipeline variable substitution.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12. Click Apply, save the integration, and then run the Integration.
An email is sent to the recipients specified in the To field on the SMTP Account Configuration page.
 

Exceptions

Timeout errors may occur while executing the sendEmail operation. Do the following as remedial actions:
  • Check if the host and port details are configured correctly.
  • Increase the Response Timeout value on the Account Configuration page.

image.png