send welcome emaail
This commit is contained in:
@@ -12,7 +12,7 @@
|
|||||||
void vars2form(CVars &v, C_CGI_Form &form);
|
void vars2form(CVars &v, C_CGI_Form &form);
|
||||||
|
|
||||||
extern int mailsend(CVars in, CVars &out);
|
extern int mailsend(CVars in, CVars &out);
|
||||||
|
long CronWelcomeAccountMail(CVars in);
|
||||||
/*
|
/*
|
||||||
|
|
||||||
CREATE TABLE email_message(
|
CREATE TABLE email_message(
|
||||||
@@ -39,5 +39,53 @@ CREATE TABLE email_message(
|
|||||||
long CronSendMail(CVars in, CVars &out){
|
long CronSendMail(CVars in, CVars &out){
|
||||||
logfmt(logINFO, " ***** CALL long CronSendMail(CVars in, CVars &out)");
|
logfmt(logINFO, " ***** CALL long CronSendMail(CVars in, CVars &out)");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
char vname[30];
|
||||||
|
long ret = PHP_API_BAD_PARAM;
|
||||||
|
try {
|
||||||
|
out["total_record"] = "0";
|
||||||
|
const PGresult *res;
|
||||||
|
res = pgsql_query("SELECT * FROM email_message WHERE topic ='WRENCHBOARD_ACCOUNT_LOGIN' AND status = 1 ORDER BY id ASC LIMIT 20");
|
||||||
|
|
||||||
|
if (res != NULL && pgsql_num_rows(res) > 0) {
|
||||||
|
out["total_record"] = pgsql_num_rows(res);
|
||||||
|
|
||||||
|
for (int i = 0, n = pgsql_num_rows(res); i < n; i++) {
|
||||||
|
map<const char*, const char*>f = pgsql_fetch_assoc(res, i);
|
||||||
|
if (f.empty()) continue;
|
||||||
|
CVars rec;
|
||||||
|
map_to_cvars(f, rec);
|
||||||
|
pgsql_query("UPDATE email_message SET status = 2 WHERE id = %lu ", rec["id"].Long()); // move the status so no retry
|
||||||
|
CronWelcomeAccountMail(rec); // send the cron email
|
||||||
|
pgsql_query("UPDATE email_message SET status = 5, completed = now() WHERE id = %lu ", rec["id"].Long()); // move the status so no retry
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ret = PHP_API_OK;
|
||||||
|
out["status"] = "OK";
|
||||||
|
} catch (bad_parameter) {
|
||||||
|
logfmt(logINFO, "ERROR CALL long WRENCHBOARD_ACCOUNT_LOGIN(CVars in, CVars &out)");
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
long CronWelcomeAccountMail(CVars in) // TESTED
|
||||||
|
{
|
||||||
|
REQ_LONG(in, "member_id", 1, -1);
|
||||||
|
CVars x;
|
||||||
|
CVars out;
|
||||||
|
CVars ml;
|
||||||
|
C_CGI_Form form("", "");
|
||||||
|
form.LetStr("main_site_url", "https://www.wrenchboard.com/");
|
||||||
|
out["server_name"] = CfgReadChar("system.server_name");
|
||||||
|
form.LetStr("server_name", out["server_name"].c_str());
|
||||||
|
form.LetStr("site_name", "WrenchBoard");
|
||||||
|
|
||||||
|
if (load_db_record(x, "SELECT *,to_char(now(), 'yyyy') AS YYYY FROM members WHERE id = %lu ", in["member_id"].Long())) {
|
||||||
|
vars2form(x, form);
|
||||||
|
form.LetStr("email", x["email"].c_str());
|
||||||
|
form.Email("ACCOUNT/member_welcome.mailfile");
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user