Sending email to multiple recipients via nodemailer

后端 未结 8 1770
青春惊慌失措
青春惊慌失措 2020-12-25 11:19

I am trying to send email to multiple recipients. For this I have created an array of recipients, but with my code I am only able to send mail to last email ID of the array

相关标签:
8条回答
  • 2020-12-25 11:51

    As far as I know you will be able to get multiple recipients like this

    "mail1@mail.com,mail2@mail.com,mail3@mail.com,mail4@mail.com"
    

    So why you don't do something like

    var maillist = '****.sharma3@****.com, ****.bussa@****.com, ****.gawri@****.com';
    
    var msg = {
        from: "******", // sender address
        to: maillist,
        subject: "Hello ✔", // Subject line
        text: "Hello This is an auto generated Email for ...  ✔", // plaintext body
        cc: "*******"    
        //  html: "<b>Hello world ✔</b>" // html body
    }
    

    I have already tried and it is working. Furthermore, from my point of view, why you have to worry about "asynchronously" or sending emails 1K times if you have the capability of sending all of them only in once without any complication?

    Anyway hope this help, answer your question or it may help somebody else

    Surely, my answer can be improved..

    0 讨论(0)
  • 2020-12-25 11:51
    var maillist = [
      '****.sharma3@****.com',
      '****.bussa@****.com',
      '****.gawri@****.com',
    ];
    
    maillist.toString();
    
    var msg = {
        from: "******", // sender address
        to: maillist,
        subject: "Hello ✔", // Subject line
        text: "Hello This is an auto generated Email for testing  from node please ignore it  ✔", // plaintext body
        cc: "*******"    
        //  html: "<b>Hello world ✔</b>" // html body
    }
    
    0 讨论(0)
提交回复
热议问题