-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
79 lines (64 loc) · 2.5 KB
/
index.js
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
var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
exports.prepare = function(Data) {
//console.log(Data);
//--------------------------------------------------
// to = Reciever Email Address
// from = Sender Email Address
// subject = Email Main Subject
// title = This title appear on top of body in h2
// body = add this parameter like plain text or html
const theUrl = 'https://vue-mailer.herokuapp.com/api/prepare?to='+Data.to+'&from='+Data.from+'&subject='+Data.subject+'&title='+Data.title+'&body='+Data.body;
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
xmlHttp.send( null );
return xmlHttp.responseText;
}
exports.prepareMarkdown = function(Data) {
//console.log(Data);
//------------------------------------------------------
// to = Reciever Email Address
// from = Sender Email Address
// subject = Email Main Subject
// title = This title appear on top of body in h2
// body = add this parameter like plain text or markdown
const theUrl = 'https://vue-mailer.herokuapp.com/api/prepare:md?to='+Data.to+'&from='+Data.from+'&subject='+Data.subject+'&title='+Data.title+'&body='+Data.body;
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
xmlHttp.send( null );
return xmlHttp.responseText;
}
/*
exports.prepare = async function(Data) {
const axios = require('axios');
var theUrl = 'https://vue-mailer.herokuapp.com/api/prepare?to='+Data.to+'&from='+Data.from+'&subject='+Data.subject+'&title='+Data.title+'&body='+Data.body;
axios.get(theUrl)
.then(function (getResponse) {
// handle success
console.log(getResponse.data);
//return getResponse.data;
})
.catch(function (error) {
// handle error
console.log(error);
})
.finally(function () {
// always executed
});
}
this.mail = function(theUrl)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
xmlHttp.send( null );
return xmlHttp.responseText;
}
this.mailCallback = function(theUrl, callback)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
callback(xmlHttp.responseText);
}
xmlHttp.open("GET", theUrl, true); // true for asynchronous
xmlHttp.send(null);
}*/