Skip to content

Commit

Permalink
Merge pull request #1111 from TransformerOptimus/email_return_statement
Browse files Browse the repository at this point in the history
Changes for no receiver address
  • Loading branch information
Tarraann authored Aug 24, 2023
2 parents 5c5a193 + de14f7f commit 83463b3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion superagi/tools/email/send_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def _execute(self, to: str, subject: str, body: str) -> str:
else:
send_to_draft = False

if message["To"] == "[email protected]" or send_to_draft:
if send_to_draft:
draft_folder = self.get_tool_config('EMAIL_DRAFT_FOLDER') or "Drafts"
imap_server = self.get_tool_config('EMAIL_IMAP_SERVER')
conn = ImapEmail().imap_open(draft_folder, email_sender, email_password, imap_server)
Expand All @@ -72,6 +72,10 @@ def _execute(self, to: str, subject: str, body: str) -> str:
str(message).encode("UTF-8")
)
return f"Email went to {draft_folder}"

if message["To"] == "[email protected]":
return "Error: Email Not Sent. Enter an Email Address."

else:
smtp_host = self.get_tool_config('EMAIL_SMTP_HOST')
smtp_port = self.get_tool_config('EMAIL_SMTP_PORT')
Expand Down
6 changes: 5 additions & 1 deletion superagi/tools/email/send_email_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def send_email_with_attachment(self, to, subject, body, attachment) -> str:
send_to_draft = True
else:
send_to_draft = False
if message["To"] == "[email protected]" or send_to_draft:
if send_to_draft:
draft_folder = self.get_tool_config('EMAIL_DRAFT_FOLDER')
imap_server = self.get_tool_config('EMAIL_IMAP_SERVER')
conn = ImapEmail().imap_open(draft_folder, email_sender, email_password, imap_server)
Expand All @@ -127,6 +127,10 @@ def send_email_with_attachment(self, to, subject, body, attachment) -> str:
str(message).encode("UTF-8")
)
return f"Email went to {draft_folder}"

if message["To"] == "[email protected]":
return "Error: Email Not Sent. Enter an Email Address."

else:
smtp_host = self.get_tool_config('EMAIL_SMTP_HOST')
smtp_port = self.get_tool_config('EMAIL_SMTP_PORT')
Expand Down

0 comments on commit 83463b3

Please sign in to comment.