diff --git a/fastapi_mail/config.py b/fastapi_mail/config.py index 2209e5e..7536231 100644 --- a/fastapi_mail/config.py +++ b/fastapi_mail/config.py @@ -2,13 +2,13 @@ from aiosmtplib.api import DEFAULT_TIMEOUT from jinja2 import Environment, FileSystemLoader -from pydantic import DirectoryPath, EmailStr, conint +from pydantic import DirectoryPath, EmailStr, SecretStr, conint from pydantic_settings import BaseSettings as Settings class ConnectionConfig(Settings): MAIL_USERNAME: str - MAIL_PASSWORD: str + MAIL_PASSWORD: SecretStr MAIL_PORT: int MAIL_SERVER: str MAIL_STARTTLS: bool diff --git a/fastapi_mail/connection.py b/fastapi_mail/connection.py index 25dd362..c41fc3a 100644 --- a/fastapi_mail/connection.py +++ b/fastapi_mail/connection.py @@ -46,7 +46,8 @@ async def _configure_connection(self) -> None: if self.settings.USE_CREDENTIALS: await self.session.login( - self.settings.MAIL_USERNAME, self.settings.MAIL_PASSWORD + self.settings.MAIL_USERNAME, + self.settings.MAIL_PASSWORD.get_secret_value(), ) except Exception as error: