Hello,
SMTP has since been depreciated by default (security defaults). You will need to utilize OAuth 2.0 as seen in the article cited below.
We've already started making this change. We now create new Microsoft 365 tenants with Basic authentication in Exchange Online turned off, because Security defaults is enabled for them.
Authenticate an IMAP, POP or SMTP connection using OAuth
If this is helpful please accept answer.