@@ -45,14 +45,19 @@ const templateParams = {
45
45
notes: ' Check this out!' ,
46
46
};
47
47
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
+ );
56
61
```
57
62
58
63
** init (optional)**
@@ -61,7 +66,10 @@ emailjs.send('<YOUR_SERVICE_ID>', '<YOUR_TEMPLATE_ID>', templateParams, '<YOUR_P
61
66
import emailjs from ' @emailjs/nodejs' ;
62
67
63
68
// 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
+ });
65
73
66
74
emailjs .send (' <YOUR_SERVICE_ID>' , ' <YOUR_TEMPLATE_ID>' ).then (
67
75
(response ) => {
@@ -79,7 +87,15 @@ emailjs.send('<YOUR_SERVICE_ID>', '<YOUR_TEMPLATE_ID>').then(
79
87
import { send , EmailJSResponseStatus } from ' @emailjs/nodejs' ;
80
88
81
89
try {
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
+ );
83
99
console .log (' SUCCESS!' );
84
100
} catch (err) {
85
101
if (err instanceof EmailJSResponseStatus) {
@@ -103,12 +119,17 @@ var templateParams = {
103
119
notes: ' Check this out!' ,
104
120
};
105
121
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
+ );
114
135
```
0 commit comments