Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: smtp #3880

Merged
merged 2 commits into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions examples/workflows/send_smtp_email.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
id: send-smtp-email
description: send hello via SMTP
triggers:
- type: manual

actions:
- name: send-email
provider:
type: smtp
config: "{{ providers.smtp }}"
with:
from_email: "[email protected]"
from_name: "Workflow user"
to_email:
- "[email protected]"
subject: "Hello from Keep workflow!"
body: "Hello! This is a test email from Keep workflow."
15 changes: 7 additions & 8 deletions keep/providers/smtp_provider/smtp_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,16 @@ def send_email(
if from_name == "":
msg["From"] = from_email
msg["From"] = f"{from_name} <{from_email}>"
msg["To"] = to_email
if to_email is str:
msg["To"] = to_email
else:
msg["To"] = ", ".join(to_email)
msg["Subject"] = subject
msg.attach(MIMEText(body, "plain"))

try:
smtp = self.generate_smtp_client()
smtp.sendmail(from_email, to_email, msg.as_string())
smtp.quit()

except Exception as e:
raise Exception(f"Failed to send email: {str(e)}")
smtp = self.generate_smtp_client()
smtp.sendmail(from_email, to_email, msg.as_string())
smtp.quit()

def _notify(
self, from_email: str, from_name: str, to_email: str, subject: str, body: str
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "keep"
version = "0.38.4"
version = "0.38.5"
description = "Alerting. for developers, by developers."
authors = ["Keep Alerting LTD"]
packages = [{include = "keep"}]
Expand Down
Loading