forked from jethavabhavik07/Email-Client
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcompose.html
More file actions
144 lines (127 loc) · 5.98 KB
/
compose.html
File metadata and controls
144 lines (127 loc) · 5.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Compose new email</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="css/custom.css">
</head>
<body>
<div class="container-compose">
<form>
<table>
<tr>
<td>To: </td>
<td><input type="text" id="to" name="to-email" class="to-compose" ></td>
</tr>
<tr>
<td>Cc: </td>
<td><input type="text" id="cc" name="cc-email" class="to-compose"></td>
</tr>
<tr>
<td>Bcc: </td>
<td><input type="text" id="bcc" name="bcc-email" class="to-compose"></td>
</tr>
<tr>
<td>Subject: </td>
<td><input type="text" id="subject" name="subject" class="to-compose"></td>
</tr>
<tr>
<td>Attach files: </td>
<td><input type="file" name="attachment" class="to-compose" style="margin: 1% 0 0 2%;"></td>
</tr>
<tr>
<td>Your message:</td>
<td>
<br>
<textarea id="message" name="message" rows="10"></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<center>
<button type="submit" class="menu-button" style="text-align: center !important">Submit</button>
</center>
</td>
</tr>
</table>
</form>
</div>
<script>
const electron = require('electron');
const {ipcRenderer} = electron;
const form = document.querySelector('form');
form.addEventListener('submit',submitform);
function submitform(e){
e.preventDefault();
// process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
// var credentials = require('./credentials.json');
/*
//var send = require('gmail-send')({
require('./index.js')({
user: credentials.user, // Your GMail account used to send emails
pass: credentials.pass, // Application-specific password
to: document.getElementById('to').value, // Send to yourself
// to: credentials.user,
cc: document.getElementById('cc').value,
bcc: document.getElementById('bcc').value,
//you can also add cc and bcc
subject: document.getElementById('subject').value,
text: document.getElementById('message').value // Plain text
})({}); */
/*require('./index.js')({
user: credentials.user, // Your GMail account used to send emails
pass: credentials.pass, // Application-specific password
to: credentials.user, // Send to yourself
subject: 'ping',
text: 'gmail-send example 2', // Plain text
})({}); // Send email without any check
*/
"use strict";
const nodemailer = require("nodemailer");
var credentials = require('./credentials.json');
// async..await is not allowed in global scope, must use a wrapper
async function main() {
// Generate test SMTP service account from ethereal.email
// Only needed if you don't have a real mail account for testing
let account = await nodemailer.createTestAccount();
// create reusable transporter object using the default SMTP transport
let transporter = nodemailer.createTransport({
host: "smtp.gmail.com",
port: 587,
secure: false, // true for 465, false for other ports
auth: {
user: 'mayur.icon2019@gmail.com', // generated ethereal user
pass: 'cinematicon' // generated ethereal password
}
});
// setup email data with unicode symbols
let mailOptions = {
from: "mayur.icon2019@gmail.com", // sender address
to: document.getElementById('to').value, // list of receivers
subject: document.getElementById('subject').value, // Subject line
text: document.getElementById('message').value, // plain text body
cc: document.getElementById('cc').value,
bcc: document.getElementById('bcc').value
};
// send mail with defined transport object
let info = await transporter.sendMail(mailOptions)
console.log("Message sent: %s", info.messageId);
// Preview only available when sending through an Ethereal account
console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));
const user1 = credentials.user;
const pass1 = credentials.pass;
const to1 = document.getElementById('to').value;
const cc1 = document.getElementById('cc').value;
const bcc1 = document.getElementById('bcc').value;
const subject1 = document.getElementById('subject').value;
const text1= document.getElementById('message').value;
alert("Mail sent successfully.");
ipcRenderer.send('mail:send',[user1, pass1, to1, cc1, bcc1, subject1, text1]);
}
main().catch(console.error);
}
</script>
</body>
</html>