charmbracelet / pop

Send emails from your terminal 📬
MIT License
2.25k stars 41 forks source link

Send from MFA organisational accounts #70

Open shemraz opened 2 months ago

shemraz commented 2 months ago

As a big fan of the charmbracelet ecosystem, I am so excited to see pop 😄

Would the ability to send mail from an institutional Outlook address be at all achievable?

maaslalani commented 2 months ago

Hey @shemraz, thanks for opening the issue. I haven't looked into institutional Outlook at all but is it possible to send email with SMTP using your account, if so then it should definitely be possible.

Alternatively, if there's some sort of API key that you can use, we could hook into that.

shemraz commented 2 months ago

Hey @maaslalani !

I've tried sending an email using my institutional Outlook account, but it throws with this error: freeze

I'm certain I have all the POPSMTP* env vars set correctly. I also tested it with my personal Outlook account and it worked like a charm. I assume the error is because my organisation/Office365 requires an OAuth connection.

I'm not too familiar with this sort of stuff, but you may find the Microsoft Graph Outlook Mail API useful. See also sendMail action and Microsoft Graph SDK for Go which looks promising!

shemraz commented 2 months ago

There was some discussion about adding this to go-simple-mail but I don't think this has been taken further. However, go-mail fully supports XOAUTH2. See SMTPAuthType in the go-mail documentation.

Perhaps pop could have an --auth.method flag and use the go-mail API to handle XOAUTH2 requests? This may be simpler than having pop itself handling authentication via the Microsoft Graph API. Looks achievable! Would love to help in any way that I can, although my Go knowledge is limited.