dalvhikkimail 1.0.1
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/06-02.js +47 -0
- package/06-03.js +11 -0
- package/06-04.js +8 -0
- package/README.txt +3 -0
- package/index.html +53 -0
- package/m0603.js +30 -0
- package/package.json +15 -0
package/06-02.js
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
const http=require('http');
|
2
|
+
const nodemailer=require('nodemailer');
|
3
|
+
const url=require('url');
|
4
|
+
const fs=require('fs');
|
5
|
+
const {parse}=require('querystring');
|
6
|
+
|
7
|
+
http.createServer((req,resp)=>{
|
8
|
+
resp.writeHead(200,{'Content-Type':'text/html; charset=utf-8'});
|
9
|
+
if(url.parse(req.url).pathname==='/'&&req.method=='GET'){
|
10
|
+
resp.end(fs.readFileSync('./index.html'));
|
11
|
+
}
|
12
|
+
else if(url.parse(req.url).pathname==='/'&&req.method=='POST'){
|
13
|
+
let body='';
|
14
|
+
req.on('data',chunk=>{
|
15
|
+
body+=chunk.toString();
|
16
|
+
});
|
17
|
+
req.on('end',()=>{
|
18
|
+
let param=parse(body);
|
19
|
+
const transporter=nodemailer.createTransport({
|
20
|
+
host: 'smtp.gmail.com',
|
21
|
+
port:587,
|
22
|
+
secure:false,
|
23
|
+
service:'Gmail',
|
24
|
+
auth:{
|
25
|
+
user:param.sender,
|
26
|
+
pass:"jwvh fzdd kpkr wcor"
|
27
|
+
//"ulll kbbl ivjy bhlc"
|
28
|
+
//"jwvh fzdd kpkr wcor"
|
29
|
+
}
|
30
|
+
})
|
31
|
+
const mailOptons={
|
32
|
+
from:param.sender,
|
33
|
+
to:param.receiver,
|
34
|
+
subject:param.topic,
|
35
|
+
text:param.message
|
36
|
+
}
|
37
|
+
|
38
|
+
transporter.sendMail(mailOptons,(err,info)=>{
|
39
|
+
if(err){
|
40
|
+
return console.log(err.message);
|
41
|
+
}
|
42
|
+
return console.log("Sent: "+info.response);
|
43
|
+
});
|
44
|
+
resp.end(`<h1>Message has been sent to ${param.receiver} from ${param.sender}</h1>`);
|
45
|
+
});
|
46
|
+
}
|
47
|
+
}).listen(5000,()=>{console.log("Server is listening at http://localhost:5000/\n")});
|
package/06-03.js
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
const senderModule=require('./m0603');
|
2
|
+
const http=require('http');
|
3
|
+
|
4
|
+
const sender = 'enjoyhockeyleague@gmail.com';
|
5
|
+
const password = 'jwvh fzdd kpkr wcor';
|
6
|
+
|
7
|
+
http.createServer((req,resp)=>{
|
8
|
+
resp.writeHead(200,{'Content-Type':'text/html; charset=utf-8'});
|
9
|
+
senderModule(sender,password,'[06-03]xd');
|
10
|
+
resp.end('<h2>Message has been sent succesfully</h2>')
|
11
|
+
}).listen(5000,()=>{console.log("Server is listening at http://localhost:5000/\n")});
|
package/06-04.js
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
const send = require('dalvhikkimail');
|
2
|
+
const http = require('http');
|
3
|
+
|
4
|
+
http.createServer((req, res) => {
|
5
|
+
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
|
6
|
+
send('[06-04] hello from dalvhikkimail GLOBAL module!');
|
7
|
+
res.end('<h2>Message sucessfully sent.</h2>');
|
8
|
+
}).listen(5000, () => console.log('Server running at localhost:5000/\n'));
|
package/README.txt
ADDED
package/index.html
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Email</title>
|
5
|
+
<style>
|
6
|
+
input{
|
7
|
+
height: 24px;
|
8
|
+
width: 250px;
|
9
|
+
border: 1px solid #dbdbdb;
|
10
|
+
border-radius: 4px;
|
11
|
+
padding: 5px;
|
12
|
+
margin-left:10px;
|
13
|
+
}
|
14
|
+
* {
|
15
|
+
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
16
|
+
font-size: 16px;
|
17
|
+
}
|
18
|
+
.row{
|
19
|
+
display: flex;
|
20
|
+
flex-direction: row;
|
21
|
+
height: 40px;
|
22
|
+
margin: -4px 0;
|
23
|
+
padding: 5px;
|
24
|
+
align-items: center;
|
25
|
+
}
|
26
|
+
</style>
|
27
|
+
</head>
|
28
|
+
<body>
|
29
|
+
<div id="container">
|
30
|
+
<form action="http://localhost:5000" method="POST">
|
31
|
+
<div class="row">
|
32
|
+
<label for="sender">From</label>
|
33
|
+
<input type="email" name="sender" id="emailSender" required/>
|
34
|
+
</div>
|
35
|
+
<div class="row">
|
36
|
+
<label for="receiver">To</label>
|
37
|
+
<input type="email" name="receiver" id="emailReceiver" required/>
|
38
|
+
</div>
|
39
|
+
<div class="row">
|
40
|
+
<label for="topicOfMes">Topic</label>
|
41
|
+
<input type="text" name="topic" id="topicOfMes"/>
|
42
|
+
</div>
|
43
|
+
<div class="row">
|
44
|
+
<label for="topicOfMes">Message</label>
|
45
|
+
<input type="text" name="message" id="Mes"/>
|
46
|
+
</div>
|
47
|
+
<div class="row">
|
48
|
+
<button type="submit">Send email</button>
|
49
|
+
</div>
|
50
|
+
</form>
|
51
|
+
</div>
|
52
|
+
</body>
|
53
|
+
</html>
|
package/m0603.js
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
const nodemailer = require('nodemailer');
|
2
|
+
|
3
|
+
const receiver = 'v.goroshchenja@gmail.com';
|
4
|
+
|
5
|
+
send = (sender, password, message) =>
|
6
|
+
{
|
7
|
+
const transporter = nodemailer.createTransport({
|
8
|
+
host: 'smtp.gmail.com',
|
9
|
+
port: 587,
|
10
|
+
secure: false,
|
11
|
+
service: 'Gmail',
|
12
|
+
auth: {
|
13
|
+
user: sender,
|
14
|
+
pass: password
|
15
|
+
}
|
16
|
+
});
|
17
|
+
|
18
|
+
const mailOptions = {
|
19
|
+
from: sender,
|
20
|
+
to: receiver,
|
21
|
+
subject: 'Module m0306',
|
22
|
+
text: message
|
23
|
+
}
|
24
|
+
|
25
|
+
transporter.sendMail(mailOptions, (err, info) => {
|
26
|
+
err ? console.log(err) : console.log('Sent: ' + info.response);
|
27
|
+
})
|
28
|
+
}
|
29
|
+
|
30
|
+
module.exports = send;
|
package/package.json
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
{
|
2
|
+
"dependencies": {
|
3
|
+
"nodemailer": "^6.9.5"
|
4
|
+
},
|
5
|
+
"name": "dalvhikkimail",
|
6
|
+
"description": "1) To install nodemailer\r \tnpm install nodemailer\r That's all for this moment. When I'll do last task, I will let you know there)",
|
7
|
+
"version": "1.0.1",
|
8
|
+
"main": "m0603.js",
|
9
|
+
"devDependencies": {},
|
10
|
+
"scripts": {
|
11
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
12
|
+
},
|
13
|
+
"author": "",
|
14
|
+
"license": "ISC"
|
15
|
+
}
|