mailing protocols
it is common to see this format of string for setting the from field of an email: Andres Estrella <andresestrella@gmail.com>
SMTP (simple mail transfer protocol)
old default port is 25
default port for encrypted email is 587
465 is sometimes used for SMTPS but this is an outdated implementation and 587 should be used.
IMAP (Internet Message Access Protocol)
default port is 993 SSL/TLS security
POP (Post Office Protocol)
port 995. It is not encrypted.
encrypted POP3 is port 995 and workd over TLS/SSL.
Microsoft mailing / SMTP servers
segun este issue y este thread, sugieren usar msGraph para enviar correos. Basic smtp auth (clear text user:pass) is deprecated. There considered temporary workarounds like app passwords, enabling per mailbox SMTP auth, etc...
Microsoft recommends msGraph SendMail endpoints or SMTP con OAuth authentication.
also called Office 365 SMTP AUTH client submission.
SMTP AUTH is disabled if organization uses Security Defaults, which it does. To enable see this
siguiendo el 'Client credentials flow' conseguimos un token que autentica a la app web en si, nos aseguramos que en azure la app tenga el app permission "send mail as any user".
Api permissions es para permisos delegados, afectan a los usuarios que se autentican. Los permisos que afectan a la aplicacion en si son los 'App Roles'. asi
En la doc de microsoft da a entender que los permisos que aplican a la aplicación son los "App Roles" pero logramos agregar el app permission "send mail as any user" dentro del mismo tab de API permissions.
Este token tambien expira, hay que implementar un mecanismo de refrescar el token o hacer la autenticacion cada vez que quiera enviar un correo.
- se puede configurar que el token expire en un maximo de 24 horas en vez de cada hora. un refresh token, si a la app se le ha dado
offline_accessscope, tiene por defecto una expiracion de 14 dias un maximo de 90 dias. configuring exampleto change lifetime policy of tokens need to use the Microsoft Graph Powershell SDK
server names

Outlook SMTP:
smtp-mail.outlook.com
port: 587
Security: STARTTLS