Today I am going to demonstrate how to set up SMTP in Sitecore Connect with the help of Python.
Sitecore Connect is a robust solution that is used for smoothly integrating your Sitecore products with other applications in your digital ecosystem. It is an integration workbench that empowers you to create connected experiences for your users, streamlining processes and improving overall user journeys. Built on Workato, it is a Low-code/No-code integration platform. This platform makes it simple for the organization to integrate Sitecore products with the other components of the IT system.
SMTP stands for Simple Mail Transfer Protocol. It is a reliable technology that powers email sending and receiving in the background. It is the language that servers and computers utilize to communicate with one another while sending user communications.
Steps
Firstly, create a recipe in Sitecore Connect. Enter the recipe name and the location for the recipe. Also, select the starting point according to your requirements. In my case, I will select the “Run on a Schedule” option.
Now, once the recipe is created select the time unit and trigger time. In my case, I have selected time unit as “minutes” and trigger time as “5”.
Now, add an action with the type “Action in an app” and select “Python snippets by Workato” from the list.
Once the action app is created, enter the name of the action app and enter the below code for SMTP in the “Code” field.
import smtplib
from email.message import EmailMessage
def main(input):
sender_mail = 'SENDER MAIL ID'
receivers_mail = 'RECEIVER MAIL ID'
msg = EmailMessage()
msg['Subject'] = "This is Subject for Mail"
msg['From'] = sender_mail
msg['To'] = receivers_mail
Text = "This is Text for Mail"
msg.set_content(Text)
try:
password = 'PASSWORD FOR SMTP CONNECTION';
smtpObj = smtplib.SMTP("YOUR MAIL SERVER", 25)
smtpObj.login(sender_mail,password)
smtpObj.send_message(msg)
print("Successfully Sent Email")
except Exception as e:
print("Error: Unable to Send Email")
print(e)
The SMTP using Python has been successfully created in Sitecore Connect. You can further debug and modify the code as required.
References
Sending Email Python - https://www.javatpoint.com/python-sending-email
Workato - https://www.workato.com
Sitecore Connect - https://developers.sitecore.com/integrations/connect
That’s All for Today,
Happy Coding
Coders for Life