| else: | else: | ||||
| smtp = smtplib.SMTP(self.server, self.port, timeout=10) | smtp = smtplib.SMTP(self.server, self.port, timeout=10) | ||||
| if self.username and self.password: | |||||
| # Only authenticate if both username and password are non-empty | |||||
| if self.username and self.password and self.username.strip() and self.password.strip(): | |||||
| smtp.login(self.username, self.password) | smtp.login(self.username, self.password) | ||||
| msg = MIMEMultipart() | msg = MIMEMultipart() |