21 lines
649 B
Python
21 lines
649 B
Python
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'),
|
||
}
|