Skip to content

Commit 497e26a

Browse files
authored
Merge pull request #376 from dhaval055/master
Updated send_email_smtp action to support cc
2 parents 655302f + 9a75d95 commit 497e26a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

email/1.3.0/api.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ actions:
8383
required: true
8484
schema:
8585
type: string
86+
- name: cc_emails
87+
description: cc_emails
88+
multiline: false
89+
90+
required: false
91+
schema:
92+
type: string
8693
- name: subject
8794
description: The subject of the email
8895
multiline: false

email/1.3.0/src/app.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def send_email_shuffle(self, apikey, recipients, subject, body):
7575
return requests.post(url, headers=headers, json=data).text
7676

7777
def send_email_smtp(
78-
self, smtp_host, recipient, subject, body, smtp_port, attachments="", username="", password="", ssl_verify="True", body_type="html"
78+
self, smtp_host, recipient, subject, body, smtp_port, attachments="", username="", password="", ssl_verify="True", body_type="html", cc_emails=""
7979
):
8080
if type(smtp_port) == str:
8181
try:
@@ -112,6 +112,10 @@ def send_email_smtp(
112112
msg["From"] = username
113113
msg["To"] = recipient
114114
msg["Subject"] = subject
115+
116+
if cc_emails != None and len(cc_emails) > 0:
117+
msg["Cc"] = cc_emails
118+
115119
msg.attach(MIMEText(body, body_type))
116120

117121
# Read the attachments
@@ -161,7 +165,7 @@ def send_email_smtp(
161165
self.logger.info("Successfully sent email with subject %s to %s" % (subject, recipient))
162166
return {
163167
"success": True,
164-
"reason": "Email sent to %s!" % recipient,
168+
"reason": "Email sent to %s, %s!" %(recipient,cc_emails) if cc_emails else "Email sent to %s!" % recipient,
165169
"attachments": attachment_count
166170
}
167171

0 commit comments

Comments
 (0)