charmbracelet / pop

Send emails from your terminal 📬
MIT License
2.36k stars 49 forks source link

Feature implementation - Email services #13

Closed ernesto27 closed 1 year ago

ernesto27 commented 1 year ago

Hi!

Is your feature request related to a problem? Please describe. This is an issue created in relation to this issue about a feature request to support multiple SMTP mails services. https://github.com/charmbracelet/pop/issues/6

Describe the solution you'd like I was thinking about this and I would like to share an approach for that.

. Create an interface for differents mails services ( resend, mailjet, sendgrid, etc) something like this

type ServiceEmail interface {
    SendEmail(to []string, from, subject, body string, paths []string) error
}

all different mails services should implement this interface in order to be used by the app.

. Add an optional new env variable to define what type of services mail will be used. for example if you want to use mailjet you should set the env variable like this POP_SERVICE_EMAIL=mailjet

If you do not create this variable, resend service will be used by default.

For different services you should create new env variables For example

MAILJET_API_KEY_PUBLIC

Also a custom type "email "struct will be created to not depend of a library struct like "resend.SendEmailRequest" ,

i am working on some implementation of this ( I have to test more but I am close to finishing it ), if you are interested I can send you a MR.

CovertDuck commented 1 year ago

That would be super neat IMO. I would also love to see SMTP support for those hosting their own mail servers.

ernesto27 commented 1 year ago

Yes, i think is possible to implement, maybe using the native golang smtp or some library ( maybe gomail ) ,

probably some new env variables should be required , something like this.

SMTP_HOST=

SMTP_PORT=

etc…

i will take a look on this.

CovertDuck commented 1 year ago

I would personally prefix every environment variable with POP_ to avoid conflicts with other applications that might be using similar environment variables. For instance, SMTP_HOST= would become POP_SMTP_HOST=. It’s a bit more verbose, but I believe it’s worth it given there is a lot of projects that will use SMTP and the gang.

maaslalani commented 1 year ago

That would be super neat IMO. I would also love to see SMTP support for those hosting their own mail servers.

SMTP support is now added btw.