dwyl / sendemail

💌 Simplifies reliably sending emails from your node.js apps using AWS Simple Email Service (SES)
182 stars 26 forks source link

sending emails to multiple addresses #86

Closed RobStallion closed 6 years ago

RobStallion commented 6 years ago

When trying to send an email to multiple email addresses at once I was getting an error.

It looks like this line is putting the toAddresses into an array. This works if you just pass in one email address as a string but it does not work if you have multiple email addresses that you need to send to at once.

I think that the person using the module should pass in an array to toAddresses themselves and the wrapping should be removed from the node module. This way we would not wrap an array within an array when sending to multiple email addresses.

This is an example of an object that I am currently trying to call the sendemail.email function with

      var object = {
        toName: 'name',
        email: ['email1@email.com', 'email2@email.com'],
        subject: 'subject',
        details: 'details'
      };

      sendemail.email("template", object, function(error, result) {
        console.log(result);
      });

Is there another way that this function is intended to be used?

nelsonic commented 6 years ago

@RobStallion good question, thanks for opening this issue! 👍 Hidden in the docs (Readme) is: https://github.com/dwyl/sendemail#more-options image

Perhaps it's time for a "Table of Contents"...? 🤔

samhstn commented 6 years ago

@nelsonic @roryc89 what are your thoughts on catering for passing in email as an array of email strings:

    var object = {
        toName: 'name',
        email: ['email1@email.com', 'email2@email.com'],
        subject: 'subject',
        details: 'details'
      };

and also catering for passing in a single email string:

    var object = {
        toName: 'name',
        email: 'email1@email.com',
        subject: 'subject',
        details: 'details'
      };

In the above example

nelsonic commented 6 years ago

@shouston3 / @RobStallion / @parkhabit I'm happy with updating the sendemail.email to accept an Array on the object.email, please write the necessary tests and (if possible) maintain backward compatibility. There are a handful of people/projects using the module: https://www.npmjs.com/package/sendemail image

samhstn commented 6 years ago

Sounds good @nelsonic

nelsonic commented 6 years ago

sendemail@3.4.0 on NPM includes @shouston3's update! 🎉 (thanks again!)