@@ -45,14 +45,19 @@ const templateParams = {
4545 notes: ' Check this out!' ,
4646};
4747
48- emailjs .send (' <YOUR_SERVICE_ID>' , ' <YOUR_TEMPLATE_ID>' , templateParams, ' <YOUR_PUBLIC_KEY>' ).then (
49- (response ) => {
50- console .log (' SUCCESS!' , response .status , response .text );
51- },
52- (err ) => {
53- console .log (' FAILED...' , err);
54- },
55- );
48+ emailjs
49+ .send (' <YOUR_SERVICE_ID>' , ' <YOUR_TEMPLATE_ID>' , templateParams, {
50+ publicKey: ' <YOUR_PUBLIC_KEY>' ,
51+ privateKey: ' <YOUR_PRIVATE_KEY>' , // optional, highly recommended for security reasons
52+ })
53+ .then (
54+ (response ) => {
55+ console .log (' SUCCESS!' , response .status , response .text );
56+ },
57+ (err ) => {
58+ console .log (' FAILED...' , err);
59+ },
60+ );
5661```
5762
5863** init (optional)**
@@ -61,7 +66,10 @@ emailjs.send('<YOUR_SERVICE_ID>', '<YOUR_TEMPLATE_ID>', templateParams, '<YOUR_P
6166import emailjs from ' @emailjs/nodejs' ;
6267
6368// set Public Key as global settings
64- emailjs .init (' <YOUR_PUBLIC_KEY>' );
69+ emailjs .init ({
70+ publicKey: ' <YOUR_PUBLIC_KEY>' ,
71+ privateKey: ' <YOUR_PRIVATE_KEY>' , // optional, highly recommended for security reasons
72+ });
6573
6674emailjs .send (' <YOUR_SERVICE_ID>' , ' <YOUR_TEMPLATE_ID>' ).then (
6775 (response ) => {
@@ -79,7 +87,15 @@ emailjs.send('<YOUR_SERVICE_ID>', '<YOUR_TEMPLATE_ID>').then(
7987import { send , EmailJSResponseStatus } from ' @emailjs/nodejs' ;
8088
8189try {
82- await emailjs .send (' <YOUR_SERVICE_ID>' , ' <YOUR_TEMPLATE_ID>' , {}, ' <YOUR_PUBLIC_KEY>' );
90+ await emailjs .send (
91+ ' <YOUR_SERVICE_ID>' ,
92+ ' <YOUR_TEMPLATE_ID>' ,
93+ {},
94+ {
95+ publicKey: ' <YOUR_PUBLIC_KEY>' ,
96+ privateKey: ' <YOUR_PRIVATE_KEY>' , // optional, highly recommended for security reasons
97+ },
98+ );
8399 console .log (' SUCCESS!' );
84100} catch (err) {
85101 if (err instanceof EmailJSResponseStatus) {
@@ -103,12 +119,17 @@ var templateParams = {
103119 notes: ' Check this out!' ,
104120};
105121
106- emailjs .send (' <YOUR_SERVICE_ID>' , ' <YOUR_TEMPLATE_ID>' , templateParams).then (
107- function (response ) {
108- console .log (' SUCCESS!' , response .status , response .text );
109- },
110- function (err ) {
111- console .log (' FAILED...' , err);
112- },
113- );
122+ emailjs
123+ .send (' <YOUR_SERVICE_ID>' , ' <YOUR_TEMPLATE_ID>' , templateParams, {
124+ publicKey: ' <YOUR_PUBLIC_KEY>' ,
125+ privateKey: ' <YOUR_PRIVATE_KEY>' , // optional, highly recommended for security reasons
126+ })
127+ .then (
128+ function (response ) {
129+ console .log (' SUCCESS!' , response .status , response .text );
130+ },
131+ function (err ) {
132+ console .log (' FAILED...' , err);
133+ },
134+ );
114135```
0 commit comments