mailgun / mailgun-js-boland

A simple Node.js helper module for Mailgun API.
http://bojand.github.io/mailgun-js
MIT License
894 stars 122 forks source link

Send to mailing list example? #256

Open oristian opened 4 years ago

oristian commented 4 years ago

Is there a way to send to a mailing list passing in a template? do you just use message().send() with the mailing list as the address? Or is there other example code I haven't been able to find?

Thanks

SerekKiri commented 4 years ago

Hey,

I don't know what do you mean by mailing list passing in a template but if you just want to send message to mails that you have in mailing list it's simple ->

    const data = {
      from: 'your@domain.com',
      to: 'mailing_list_name@yourdomain.com', <- here you put your mailing list name before @
      subject: 'Example message',
      html: '<p>Example message</p>'
    }

      await mg.messages().send(data, function(error, body) {
        return error
      })

Hope I helped 👍