wneessen / go-mail

📧 Easy to use, yet comprehensive library for sending mails with Go
https://go-mail.dev
MIT License
571 stars 44 forks source link

Method SetBodyHTML, without Template #154

Closed suntong closed 10 months ago

suntong commented 10 months ago

Is your feature request related to a problem? Please describe.

The m.SetBodyHTMLTemplate would make it very difficult to programmatically switching between sending plain text or html email, while having a m.SetBodyHTML would make the task trivial.

Describe the solution you'd like

Can we have m.SetBodyHTML that accept a html body string, instead of a template and a d interface{} please?

Please consider. thx. I can work on the PR.

Describe alternatives you've considered

No response

Additional context

No response

wneessen commented 10 months ago

Hi @suntong,

you can already send simple HTML mails by just using SetBodyString() with TypeTextHTML as your content type. Example: m.SetBodyString(TypeTextHTML, "<p>This is HTML</p>". If you wanna combine HTML and Text parts, you can make use of m.AddAlternativeString() with the alternative content type.

References:

The reason we have HTML and Text of the functions that accept templates is, that they make use of the two different template packages from the standard library and therefore need to be distinguished by name.

suntong commented 10 months ago

Oh, thanks!