(FRONT) FRONT (2024)

My workable Node mailing templates (with Brevo and Resend Post servers, on JS and TS with Dotenv, with native packages and directly with fetching API, with sync/async/IIFE templates).

20 ears ago I working as administrator of POST server Опыт работы почтовым администратором., many times I have tuned my own Post servers, for example Избавляемся от MS Exchange на Window-платформе (hMailServer + ASSP). Also I made millions times mailing in server side, for example Поштові розсилки через Gmail., but now I want to speak about Javascript/Typescript mailing.

Pay attention, that we speak exclusively about server side mailing, this is not mailing from Browser, despite we speak about Javascript. Because this functions can not be working on Borwser.



So, I have a couple of workable code templates and I have uploaded it now to Github https://github.com/Alex1998100/MyMailingTemplates. And now I want to do a couple of comments to this code.

Firstly, my investigation show me that Resend server need own domain



However Brevo server not require that and mailing is possible without own domain (but you need to use same account what you was to register in Brevo) But Brevo return positive result in any case, even sending mail will be discard.



Secondary, if we going from JS to TS we will faced with two issues. First we need to support Dotenv package and need to make strong definition of your config. Next big problem with Typescript that we need transform anonymous object to as SMTPTransport.Options. This is what we need to do:



Third, usually we have 3 different way to mailing:

  1. With native package, provided by owner of Post server, for example this is package from Brevo https://developers.brevo.com/reference/sendtransacemail
  2. With common well-known package, what support SMTP communication, like Nodemailer https://www.jsdelivr.com/package/npm/nodemailer, you can see a couple this screens above.

  3. With REST API provided by owner of POST server. Pay attention that we have two different way to call REST API relatively old way XMLHttpRequest and relatively new way - embedded to JS Feach function. This is, for example, list of Brevo endpoint and this is example how to call Brevo endpoint.



And finally, forth deviation of JS mailing, we can send mailing (1) synchronously, (2) can mailing in immediate executing function, like on screen above, or (3) can create Task in style async()=> what we will waiting, something like this:









Related pages:



Comments ( )
Link to this page: http://www.vb-net.com/NodeMailing/Index.htm
< THANKS ME>