Compare commits

...
2 Commits
Author SHA1 Message Date
pvincent ef31c26525 tagged as 1.8.2 2021-08-27 17:41:56 +04:00
pvincent ed931b7b2c App.sendMail 2021-08-27 17:41:44 +04:00
5 changed files with 38 additions and 13 deletions
+1
View File
@@ -35,3 +35,4 @@ www/css/*.css
!www/css/bootstrap.min.css
config-dev.xml
config-prod.xml
+1 -1
View File
@@ -1 +1 @@
1.8.1
1.8.2
+1 -1
View File
@@ -47,5 +47,5 @@
"bugs": {
"url": "https://github.com/bablukid/cagette/issues"
},
"version": "1.8.1"
"version": "1.8.2"
}
+1 -1
View File
@@ -233,7 +233,7 @@ class App extends sugoi.BaseApp {
var mailer:sugoi.mail.IMailer = new sugoi.mail.BufferedMailer();
if (App.config.DEBUG) {
// Dev env : emails are written to tmp folder
App.log("DEBUGEmailer enabled => emails are written to tmp folder");
mailer = new sugoi.mail.DebugMailer();
} else {
if (sugoi.db.Variable.get("mailer") == null) {
+34 -10
View File
@@ -38,8 +38,13 @@ class Messages extends Controller {
if (form.checkToken()) {
var listId = form.getElement("list").value;
var dest = getSelection(listId);
var subject = form.getValueOf("subject");
App.log('about to send emails to listId=<$listId> to destination=${dest.length}');
App.log('about to send email <$subject> to listId=<$listId> to ${dest.length} recipient(s)');
// Sys.command("sh", [
// "-c",
// "sendemail -f no-reply@comptoirduvrac.re -s mail1.zourit.net:587 -t pvincent@comptoirduvrac.re -bcc 'pvincent974@gmail.com, pvincent974@laposte.net' -u TEST -m coucou -xu postmaster@comptoirduvrac.re -xp QqQeAPT6EpoK"
// ]);
var mails = [];
for (d in dest) {
@@ -51,15 +56,25 @@ class Messages extends Controller {
// send mail confirmation link
var e = new sugoi.mail.Mail();
e.setSubject(form.getValueOf("subject"));
for (x in mails)
e.addRecipient(x);
e.setSender(App.config.get("default_email"));
e.setSubject(subject);
e.setSender(App.config.get("default_email"), form.getValueOf("senderName"));
e.setReplyTo(form.getValueOf("senderMail"), form.getValueOf("senderName"));
var replyTo = form.getValueOf("senderMail");
var replyToName = form.getValueOf("senderName");
if (replyTo != null)
e.setReplyTo(replyTo, replyToName);
App.log('add CC header to message: ${e.getSubject()}');
e.setHeader("CC", "pvincent@comptoirduvrac.re");
if (mails.length > 1) {
var cc = mails.join(",");
App.log('add header Cc: $cc');
e.setHeader("CC:", cc);
// for (x in mails)
// e.addRecipient(x);
e.addRecipient(e.getSender().email);
} else {
App.log('no header');
e.addRecipient(mails[0]);
}
// sender : default email ( explicitly tells that the server send an email on behalf of the user )
// e.setHeader("Sender", App.config.get("default_email"));
@@ -67,12 +82,21 @@ class Messages extends Controller {
var html = app.processTemplate("mail/message.mtt", {text: text, group: app.user.amap, list: getListName(listId)});
e.setHtmlBody(html);
App.sendMail(e, app.user.getAmap(), listId, app.user);
// App.sendMail(e, app.user.getAmap(), listId, app.user);
// Sys.command("sendemail", [
// "-f", "no-reply@comptoirduvrac.re", "-s", "mail1.zourit.net:587", "-t", "pvincent@comptoirduvrac.re", "-bcc",
// "pvincent974@gmail.com,pvincent974@laposte.net", "-u", subject, "-m", "alors tout va bien", "-xu", "postmaster@comptoirduvrac.re", "-xp",
// "QqQeAPT6EpoK"
// ]);
sys.io.File.saveContent('/tmp/my_file.json', "CONTENT");
// store message
var lm = new db.Message();
lm.amap = app.user.amap;
lm.recipients = Lambda.array(Lambda.map(e.getRecipients(), function(x) return x.email));
// lm.recipients = Lambda.array(Lambda.map(e.getRecipients(), function(x) return x.email));
lm.recipients = mails;
lm.title = e.getSubject();
lm.date = Date.now();
lm.body = e.getHtmlBody();