sendemail is working
This commit is contained in:
+33
-20
@@ -77,10 +77,14 @@ class App extends sugoi.BaseApp {
|
||||
}
|
||||
|
||||
public static function log(t:Dynamic, ?infos:haxe.PosInfos) {
|
||||
// if (App.config.DEBUG) {
|
||||
// neko.Web.logMessage(Std.string(t)); // write in Apache error log
|
||||
// }
|
||||
neko.Web.logMessage('[${infos.fileName}:${infos.lineNumber} ${infos.className}#${infos.methodName}] ' + Std.string(t));
|
||||
var message:String = '[${infos.fileName}:${infos.lineNumber} ${infos.className}#${infos.methodName}] ';
|
||||
message += Std.string(t);
|
||||
|
||||
// trace(message);
|
||||
if (neko.Web.isModNeko)
|
||||
neko.Web.logMessage(message);
|
||||
else
|
||||
Sys.println(message);
|
||||
}
|
||||
|
||||
public function event(e:Event) {
|
||||
@@ -230,24 +234,34 @@ class App extends sugoi.BaseApp {
|
||||
}
|
||||
|
||||
public static function getMailer():sugoi.mail.IMailer {
|
||||
var mailer:sugoi.mail.IMailer = new sugoi.mail.BufferedMailer();
|
||||
var typeOfMailer = sugoi.db.Variable.get("mailer");
|
||||
App.log('type of mailer is <$typeOfMailer>');
|
||||
|
||||
if (typeOfMailer == null) {
|
||||
var msg = sugoi.i18n.Locale.texts._("Please configure the email settings in a <href='/admin/emails'>this section</a>");
|
||||
throw sugoi.ControllerAction.ErrorAction("/", msg);
|
||||
}
|
||||
|
||||
if (App.config.DEBUG) {
|
||||
App.log("DEBUGEmailer enabled => emails are written to tmp folder");
|
||||
mailer = new sugoi.mail.DebugMailer();
|
||||
} else {
|
||||
if (sugoi.db.Variable.get("mailer") == null) {
|
||||
var msg = sugoi.i18n.Locale.texts._("Please configure the email settings in a <href='/admin/emails'>this section</a>");
|
||||
throw sugoi.ControllerAction.ErrorAction("/", msg);
|
||||
}
|
||||
App.log('mailer in DEBUG mode, no deferred mail from CRON');
|
||||
|
||||
if (sugoi.db.Variable.get("mailer") == "mandrill") {
|
||||
// Buffered emails with Mandrill
|
||||
untyped mailer.defineFinalMailer("mandrill");
|
||||
} else {
|
||||
// Buffered emails with SMTP
|
||||
untyped mailer.defineFinalMailer("smtp");
|
||||
}
|
||||
var conf = {
|
||||
smtp_host: sugoi.db.Variable.get("smtp_host"),
|
||||
smtp_port: sugoi.db.Variable.getInt("smtp_port"),
|
||||
smtp_user: sugoi.db.Variable.get("smtp_user"),
|
||||
smtp_pass: sugoi.db.Variable.get("smtp_pass")
|
||||
};
|
||||
|
||||
return new sugoi.mail.SendEmailMailer().init(conf);
|
||||
}
|
||||
|
||||
var mailer:sugoi.mail.IMailer = new sugoi.mail.BufferedMailer();
|
||||
if (sugoi.db.Variable.get("mailer") == "mandrill") {
|
||||
// Buffered emails with Mandrill
|
||||
untyped mailer.defineFinalMailer("mandrill");
|
||||
} else {
|
||||
// Buffered emails with SMTP
|
||||
untyped mailer.defineFinalMailer("smtp");
|
||||
}
|
||||
return mailer;
|
||||
}
|
||||
@@ -265,7 +279,6 @@ class App extends sugoi.BaseApp {
|
||||
|
||||
App.log('about to send email with subject=<${m.getSubject()}> ...');
|
||||
getMailer().send(m, params, function(o) {});
|
||||
App.log('email from=<${m.getSender().email}>, subject=<${m.getSubject()}> successfully sent');
|
||||
}
|
||||
|
||||
public static function quickMail(to:String, subject:String, html:String, ?group:db.Amap) {
|
||||
|
||||
Reference in New Issue
Block a user