We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It would be nice to be able to pass url instead of connection parameters.
The text was updated successfully, but these errors were encountered:
Possible implementation:
from typing import Dict, Union from urllib.parse import urlparse def parse_smtp_url(url: str) -> Dict[str, Union[str, int]]: """Parse SMTP url to parameters to be used in aiosmtplib. Args: url: [proto://[username:password@]]host[:port][/socket_path] Returns: dict of aiosmtplib kwargs. """ parsed_url = urlparse(url) mail_settings = { 'hostname': parsed_url.hostname, 'port': parsed_url.port, 'username': parsed_url.username, 'password': parsed_url.password, 'socket_path': parsed_url.path, } if parsed_url.scheme == 'smtps': mail_settings['use_tls'] = True elif parsed_url.scheme == 'smtp+tls': mail_settings['start_tls'] = True return { parameter: param_value for parameter, param_value in mail_settings.items() if param_value }
Sorry, something went wrong.
No branches or pull requests
It would be nice to be able to pass url instead of connection parameters.
The text was updated successfully, but these errors were encountered: