-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsmtp.debug.js
63 lines (63 loc) · 2.35 KB
/
smtp.debug.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
Email = {
send: function (from, to, subject, body, host, username, password) {
var nocache = Math.floor((Math.random() * 1000000) + 1);
var strUrl = "https://smtpjs.com/smtp.aspx?";
strUrl += "From=" + from;
strUrl += "&to=" + to;
strUrl += "&Subject=" + encodeURIComponent(subject);
strUrl += "&Body=" + encodeURIComponent(body);
if (host.token == undefined) {
strUrl += "&Host=" + host;
strUrl += "&Username=" + username;
strUrl += "&Password=" + password;
strUrl += "&Action=Send";
}
else {
strUrl += "&SecureToken=" + host.token;
strUrl += "&Action=SendFromStored";
}
strUrl += "&cachebuster=" + nocache;
Email.ajax(strUrl);
},
sendWithAttachment: function (from, to, subject, body, host, username, password, attachment) {
var nocache = Math.floor((Math.random() * 1000000) + 1);
var strUrl = "https://smtpjs.com/smtp.aspx?";
strUrl += "From=" + from;
strUrl += "&to=" + to;
strUrl += "&Subject=" + encodeURIComponent(subject);
strUrl += "&Body=" + encodeURIComponent(body);
strUrl += "&Attachment=" + encodeURIComponent(attachment);
if (host.token == undefined) {
strUrl += "&Host=" + host;
strUrl += "&Username=" + username;
strUrl += "&Password=" + password;
strUrl += "&Action=Send";
}
else {
strUrl += "&SecureToken=" + host.token;
strUrl += "&Action=SendFromStored";
}
strUrl += "&cachebuster=" + nocache;
Email.ajax(strUrl);
},
ajax: function (src) {
var xhr = Email.createCORSRequest('GET', src);
xhr.onload = function () {
var responseText = xhr.responseText;
console.log(responseText);
};
xhr.send();
},
createCORSRequest: function (method, url) {
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr) {
xhr.open(method, url, true);
} else if (typeof XDomainRequest != "undefined") {
xhr = new XDomainRequest();
xhr.open(method, url);
} else {
xhr = null;
}
return xhr;
}
};