0
import asyncio

from fastapi_mail import FastMail, MessageSchema, ConnectionConfig

conf = ConnectionConfig(
    MAIL_USERNAME="здесь емаил с подключенным smtp",
    MAIL_PASSWORD="здесь пароль для smtp",
    MAIL_FROM="здесь емаил с подключенным smtp",
    MAIL_PORT=465,
    MAIL_SERVER="smtp.yandex.ru",
    MAIL_FROM_NAME="title",
    MAIL_TLS=False,
    MAIL_SSL=True,
    USE_CREDENTIALS=False,
    VALIDATE_CERTS=True
)

message = MessageSchema(
    subject="Fastapi-Mail module",
    recipients=['Здесь емаил кому отправляю'],
    # List of recipients, as many as you can pass
    body='test text'
)

fm = FastMail(conf)


async def run():
    await fm.send_message(message)


loop = asyncio.get_event_loop()
future = asyncio.ensure_future(run())
loop.run_until_complete(future)
loop.close()

Ошибка:

File "C:\Python310\lib\site-packages\aiosmtplib\esmtp.py", line 271, in mail
    raise SMTPSenderRefused(response.code, response.message, sender)
aiosmtplib.errors.SMTPSenderRefused: (503, '5.5.4 Error: send AUTH command first. какой-то код', 'здесь емаил с подключенным smtp')
1
  • 1
    Я не работал, но USE_CREDENTIALS=False выглядит очень подозрительно
    – Alexey Ten
    11 окт 2022 в 11:32

0

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.