snippets_py
Integration
New integration from credential
smtp = yepcode.integration.smtp('credential-slug')
New integration from plain authentication data
import smtplib
smtp = smtplib.SMTP("host", "port")
# If you need SSL
# smtp = smtplib.SMTP_SSL("host", "port")
smtp.login("username", "password")
# You should use a yepcode env variable to don't store plain password
# See: https://docs.yepcode.io/docs/processes/team-variables
Verify SMTP Connection Configuration
Verify SMTP connection configuration
smtp.noop()
Send Mail
Send mail (plain text)
try:
mail_content = "Subject: Mail subject\n\n"
mail_content += "Some message.\n"
smtp.sendmail("sender_email", "receiver_email", mail_content)
print("Email sent successfully!")
except Exception as e:
print(f"Error sending email: {e}")
Send mail
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
sender_email = "sender_email"
receiver_email = "receiver_email"
body = """
<h1>Hello from YepCode</h1>
<p>This is a test email sent using Python</p>
"""
message = MIMEMultipart()
message["From"] = sender_email
message["To"] = receiver_email
message["Subject"] = "Hello, World! Sent from YepCode"
message.attach(MIMEText(body, "html"))
try:
smtp.sendmail(sender_email, receiver_email, message.as_string())
print("Email sent successfully!")
except Exception as e:
print(f"Error sending email: {e}")