2025-05-05 00:47:57 +03:00

21 lines
649 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import configparser
from pathlib import Path
from typing import Dict
def load_mail_config(path: Path) -> Dict[str, str]:
"""
Читает mail.conf и возвращает словарь с настройками SMTP:
host, port, username, password, from, to
"""
cfg = configparser.ConfigParser()
cfg.read(path, encoding='utf-8')
smtp = cfg['smtp']
return {
'host': smtp.get('host'),
'port': smtp.getint('port', fallback=587),
'username': smtp.get('username'),
'password': smtp.get('password'),
'from': smtp.get('from'),
'to': smtp.get('to'),
}