API - allow EMAIL_URL without authentication - fix #127
This commit is contained in:
@ -110,7 +110,8 @@ class Email:
|
||||
with self.smtp(
|
||||
self.host, self.port, **connection_params # type: ignore
|
||||
) as smtp:
|
||||
smtp.login(self.username, self.password) # type: ignore
|
||||
if self.username and self.password:
|
||||
smtp.login(self.username, self.password) # type: ignore
|
||||
if self.use_tls:
|
||||
smtp.starttls(context=context)
|
||||
smtp.sendmail(self.sender_email, recipient, message.as_string())
|
||||
|
@ -9,7 +9,9 @@ def parse_email_url(email_url: str) -> Dict:
|
||||
parsed_url = parse_url(email_url)
|
||||
if parsed_url.scheme != 'smtp':
|
||||
raise InvalidEmailUrlScheme()
|
||||
credentials = parsed_url.auth.split(':')
|
||||
credentials = (
|
||||
parsed_url.auth.split(':') if parsed_url.auth else [None, None]
|
||||
)
|
||||
return {
|
||||
'host': parsed_url.host,
|
||||
'port': parsed_url.port,
|
||||
|
Reference in New Issue
Block a user