SIENTIAPDE-1172
fix: add conditional login for SMTP server and enhance test coverage - Updated the Email class to conditionally log in to the SMTP server only if a sender password is provided, improving security. - Enhanced test cases for the try_send_email method to cover various scenarios, including successful email sending and handling SMTP disconnections.
This commit is contained in:
@@ -125,8 +125,9 @@ class Email(BaseActivity):
|
||||
|
||||
self.server = smtplib.SMTP(
|
||||
self.smtp_server, self.smtp_port, timeout=20)
|
||||
self.server.starttls()
|
||||
self.server.login(self.sender_email, self.sender_password)
|
||||
if self.sender_password:
|
||||
self.server.starttls()
|
||||
self.server.login(self.sender_email, self.sender_password)
|
||||
self.server.sendmail(self.sender_email, receivers, msg.as_string())
|
||||
|
||||
@activity.defn(name="send_email")
|
||||
|
||||
Reference in New Issue
Block a user