node-email-sending 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index,js.js +45 -0
- package/package.json +21 -0
package/index,js.js
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
async function nodeEmailSending(data){
|
2
|
+
try{
|
3
|
+
const nodemailer = require("nodemailer");
|
4
|
+
//let testAccount = await nodemailer.createTestAccount();
|
5
|
+
|
6
|
+
//Creating transport
|
7
|
+
|
8
|
+
let transporter = nodemailer.createTransport({
|
9
|
+
host:data.host ,
|
10
|
+
port:data.port,
|
11
|
+
secure: false, // true for 465, false for other ports
|
12
|
+
auth: {
|
13
|
+
user: data.user, // generated ethereal user
|
14
|
+
pass: data.password, // generated ethereal password
|
15
|
+
},
|
16
|
+
});
|
17
|
+
|
18
|
+
// send mail with defined transport object
|
19
|
+
|
20
|
+
let info = await transporter.sendMail({
|
21
|
+
from: data.user, // sender address
|
22
|
+
to: data.emailto,// list of receivers
|
23
|
+
subject: data.subject,// Subject line
|
24
|
+
text: data.text,
|
25
|
+
html: data.html
|
26
|
+
});
|
27
|
+
console.log(info,"Message sent: %s", info.messageId);
|
28
|
+
return true
|
29
|
+
|
30
|
+
}catch(err){
|
31
|
+
throw err
|
32
|
+
}
|
33
|
+
}
|
34
|
+
let data ={
|
35
|
+
host:"smtp.ethereal.email",
|
36
|
+
post:587,
|
37
|
+
secure:false,
|
38
|
+
user:"lmu2vjcfge6nyt5y@ethereal.emai",
|
39
|
+
password:"k8c4Uyx9bWcKEqv8pb",
|
40
|
+
emailto:"pawan.bhumca15@gmail.com",
|
41
|
+
subject:"Hello",
|
42
|
+
text:"Hello world?", // plain text body
|
43
|
+
html:"<b>Hello world?</b>", // html body
|
44
|
+
}
|
45
|
+
console.log(nodeEmailSending(data))
|
package/package.json
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
{
|
2
|
+
"name": "node-email-sending",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "This package is complete pack to send email in nodejs through nodemailer",
|
5
|
+
"main": "index.js",
|
6
|
+
"scripts": {
|
7
|
+
"test": "npm install node-email-sending"
|
8
|
+
},
|
9
|
+
"keywords": [
|
10
|
+
"nodes",
|
11
|
+
"email",
|
12
|
+
"nodemailer",
|
13
|
+
"emailsendingin",
|
14
|
+
"nodejs"
|
15
|
+
],
|
16
|
+
"author": "Pawan Kumar",
|
17
|
+
"license": "ISC",
|
18
|
+
"dependencies": {
|
19
|
+
"nodemailer": "^6.7.7"
|
20
|
+
}
|
21
|
+
}
|