sabuhish / fastapi-mail

Fastapi mail system sending mails(individual, bulk) attachments(individual, bulk)
https://sabuhish.github.io/fastapi-mail/
MIT License
673 stars 82 forks source link

Response 501: 5.5.4 Invalid Domain Name #205

Open LuckyLub opened 10 months ago

LuckyLub commented 10 months ago

When using an MS Outlook account and trying to send message from my local machine, I get the following error:

SMTPHeloError(response.code, response.message)
aiosmtplib.errors.SMTPHeloError: (501, '5.5.4 Invalid domain name [AS4P189CA0060.EURP189.PROD.OUTLOOK.COM 2023-10-24T06:56:46.567Z 08DBD2CBA8497480]')

After some digging I found out that apparently the outlook server is quite strict on what domain names it accepts. There currently is no way to specify this domain name in fastapi-mail. The package which is used for making the connetion to the SMTP server is aiosmtplib, which if not provided with a local hostname, uses the socket.getfqdn() as default. Unfortunately, in my case this raises the above mentioned error, since this function results in "mylaptopname.". This does not comply with the FQDN rules MS follows.

Therefore I have made a pull request, allowing to specify the local hostname. #204