Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
diogomartino committed Jun 17, 2018
1 parent 797f4c3 commit 1bea46d
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions sampmailjs.inc
Expand Up @@ -13,7 +13,7 @@
#define SAMPMAILJS_URL "127.0.0.1:8080" // IP + PORT of the server running the NodeJS script
#define SAMPMAILJS_PASSWORD "changeme" // This password should be the same as the NodeJS script
#define SAMPMAILJS_CONSOLELOG 0 // Log some information on console
#define SAMPMAILJS_MAXPOSTDATA 2048 // Cellsize of the variable that holds the data sent to the script. Lower for small emails, higher for more extense emails
#define SAMPMAILJS_MAXPOSTDATA 1024 // Cellsize of the variable that holds the data sent to the script. Lower for small emails, higher for more extense emails

new uniqueID = 0;

Expand All @@ -22,29 +22,30 @@ public HandleHTTPResponse(index, response_code, data[]) {
uniqueID++;

#if SAMPMAILJS_CONSOLELOG == 1
printf("\n[SAMPMAILJS] Server returned a response %d", response_code);
printf("\n[SAMPMAILJS] Server returned a response %d", response_code);
#endif

if (response_code == SAMPMAILJS_RESPONSE_OK) {
#if SAMPMAILJS_CONSOLELOG == 1
printf("\n[SAMPMAILJS] Email %d sent successfully", uniqueID);
#endif
#if SAMPMAILJS_CONSOLELOG == 1
printf("\n[SAMPMAILJS] Email %d sent successfully", uniqueID);
#endif
}

return response_code;
}

stock SendEmail(name[], to[], subject[], text[], bool:isTemplate = false, templateName[] = "default.html") {
new string[64], postData[SAMPMAILJS_MAXPOSTDATA];
new string[128], postData[SAMPMAILJS_MAXPOSTDATA];

if(isTemplate) {
format(string, sizeof string, "%s/sampmail.js?pw=%s&action=sendmtmp", SAMPMAILJS_URL, SAMPMAILJS_PASSWORD);
format(postData, sizeof postData, "%s|%s|%s|%s|%s", name, to, subject, text, templateName);
}
else {
format(string, sizeof string, "%s/sampmail.js?pw=%s&action=sendm", SAMPMAILJS_URL, SAMPMAILJS_PASSWORD);
format(postData, sizeof postData, "%s|%s|%s|%s", name, to, subject, text);
format(string, sizeof string, "%s/sampmail.js?pw=%s&action=sendm", SAMPMAILJS_URL, SAMPMAILJS_PASSWORD);
format(postData, sizeof postData, "%s|%s|%s|%s", name, to, subject, text);
}

return HTTP(uniqueID, HTTP_POST, string, ret_utf8encode(postData), "HandleHTTPResponse");
utf8encode(postData, postData);
return HTTP(uniqueID, HTTP_POST, string, postData, "HandleHTTPResponse");
}

0 comments on commit 1bea46d

Please sign in to comment.