Add HTTP request support for email
This commit is contained in:
@@ -8,6 +8,13 @@
|
|||||||
// TYPE: Server (JavaScript)
|
// TYPE: Server (JavaScript)
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
|
// Email Methods
|
||||||
|
const AGRP_EMAIL_METHOD_NONE = 0; // None
|
||||||
|
const AGRP_EMAIL_METHOD_SMTP_MODULE = "smtp"; // Use SMTP module
|
||||||
|
const AGRP_EMAIL_METHOD_GET_REQUEST = "http"; // Use HTTP request (httpGet to custom PHP page)
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
function initEmailScript() {
|
function initEmailScript() {
|
||||||
logToConsole(LOG_INFO, "[AGRP.Email]: Initializing email script ...");
|
logToConsole(LOG_INFO, "[AGRP.Email]: Initializing email script ...");
|
||||||
logToConsole(LOG_INFO, "[AGRP.Email]: Email script initialized successfully!");
|
logToConsole(LOG_INFO, "[AGRP.Email]: Email script initialized successfully!");
|
||||||
@@ -16,6 +23,8 @@ function initEmailScript() {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
async function sendEmail(toEmail, toName, subject, body) {
|
async function sendEmail(toEmail, toName, subject, body) {
|
||||||
|
switch (getEmailConfig().method) {
|
||||||
|
case AGRP_EMAIL_METHOD_SMTP_MODULE:
|
||||||
if (!checkForSMTPModule()) {
|
if (!checkForSMTPModule()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -35,6 +44,32 @@ async function sendEmail(toEmail, toName, subject, body) {
|
|||||||
getEmailConfig().smtp.fromName
|
getEmailConfig().smtp.fromName
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AGRP_EMAIL_METHOD_GET_REQUEST:
|
||||||
|
let tempURL = getEmailConfig().http.baseUrl;
|
||||||
|
tempURL = tempURL.replace("{0}", encodeURI(password));
|
||||||
|
tempURL = tempURL.replace("{1}", encodeURI(toEmail));
|
||||||
|
tempURL = tempURL.replace("{2}", encodeURI(toName));
|
||||||
|
tempURL = tempURL.replace("{3}", encodeURI(subject));
|
||||||
|
tempURL = tempURL.replace("{4}", encodeURI(body));
|
||||||
|
|
||||||
|
httpGet(
|
||||||
|
tempURL,
|
||||||
|
"",
|
||||||
|
function (data) {
|
||||||
|
|
||||||
|
},
|
||||||
|
function (data) {
|
||||||
|
}
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user