adonisjs / mail

AdonisJS Email Provider
MIT License
106 stars 34 forks source link

Use the Mail API with HTML without edge views #21

Closed franciscosucre closed 6 years ago

franciscosucre commented 6 years ago

I have an application where the user writes the mail content in a HTML editor, currenty in Adonis i cannot find a way to send an email with an HTML String so i have to use the aws-sdk directly. I would like yo have a way to use the Mail API

franciscosucre commented 6 years ago

Well, i got it working like this:

    for (let i = 0; i < 2; i++) {
      const email = emailList[i];
      await Mail.send('emails.reset', {
        email: email
      }, (message) => {
        console.log("email: ", email)
        message.to("frank91frank@gmail.com")
        message.from(Config.get('mail.ses.sender'))
        message.subject('Reset your password')
        message.html('<b>Hola</b>')
      })
    }

I got to it by reading the source code because it is not on the docs. This is a great framework! But it needs works on the documentation /:

thetutlage commented 6 years ago

Which part is not in the docs?

franciscosucre commented 6 years ago

hello @thetutlage the html method is not on the documentation which led me to think i could not send a custom HTML mail. Also, should i use the raw function for my case? Thanks.

thetutlage commented 6 years ago

Okay, I will document it. I don't think the raw function will work, since it will set plainText of the email. But I can make it smart to find if HTML is passed to this function, then it will set email HTML body, otherwise will set the plainText body.