reply-to missing yet
This commit is contained in:
@@ -41,11 +41,6 @@ class Messages extends Controller {
|
|||||||
var subject = form.getValueOf("subject");
|
var subject = form.getValueOf("subject");
|
||||||
|
|
||||||
App.log('about to send email <$subject> to listId=<$listId> to ${dest.length} recipient(s)');
|
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 = [];
|
var mails = [];
|
||||||
for (d in dest) {
|
for (d in dest) {
|
||||||
if (d.email != null)
|
if (d.email != null)
|
||||||
@@ -64,17 +59,8 @@ class Messages extends Controller {
|
|||||||
if (replyTo != null)
|
if (replyTo != null)
|
||||||
e.setReplyTo(replyTo, replyToName);
|
e.setReplyTo(replyTo, replyToName);
|
||||||
|
|
||||||
if (mails.length > 1) {
|
for (x in mails)
|
||||||
var cc = mails.join(",");
|
e.addRecipient(x);
|
||||||
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 )
|
// sender : default email ( explicitly tells that the server send an email on behalf of the user )
|
||||||
// e.setHeader("Sender", App.config.get("default_email"));
|
// e.setHeader("Sender", App.config.get("default_email"));
|
||||||
|
|||||||
@@ -40,53 +40,62 @@ class SendEmailMailer implements IMailer {
|
|||||||
return mailer;
|
return mailer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function send(e:sugoi.mail.IMail, ?params:Dynamic, ?callback:MailerResult->Void) {
|
private function fromString(name:String, email:String) {
|
||||||
var mailServer = "mail1.zourit.net";
|
return (name == null) ? email : '${name} <${email}>';
|
||||||
var mailPort = 587;
|
}
|
||||||
|
|
||||||
var fromName = "John Doe";
|
public function send(e:sugoi.mail.IMail, ?params:Dynamic, ?callback:MailerResult->Void) {
|
||||||
var fromEmail = "no-reply@comptoirduvrac.re";
|
var to:String;
|
||||||
|
var bcc:String;
|
||||||
|
|
||||||
|
var recipientCounts = e.getRecipients().length;
|
||||||
|
if (recipientCounts > 1) {
|
||||||
|
to = fromString(e.getSender().name, e.getSender().email);
|
||||||
|
bcc = [for (i in e.getRecipients()) i.email].join(",");
|
||||||
|
App.log('recipients has been transformed to ${recipientCounts} bcc');
|
||||||
|
App.log(bcc);
|
||||||
|
} else {
|
||||||
|
to = e.getRecipients()[0].email;
|
||||||
|
bcc = "";
|
||||||
|
}
|
||||||
|
|
||||||
var args = [
|
var args = [
|
||||||
"-f",
|
// arguments
|
||||||
'${fromName} <${fromEmail}>',
|
|
||||||
"-s",
|
"-s",
|
||||||
"mail1.zourit.net:587",
|
'${this.m.host}:${this.m.port}',
|
||||||
|
"-xu",
|
||||||
|
${this.m.auth.username},
|
||||||
|
"-xp",
|
||||||
|
${this.m.auth.password},
|
||||||
|
"-o",
|
||||||
|
"message-charset=utf-8",
|
||||||
|
"-o",
|
||||||
|
"message-format=html",
|
||||||
|
"-o",
|
||||||
|
"X-Mailer=CagettePei",
|
||||||
|
"-f",
|
||||||
|
fromString(e.getSender().name, e.getSender().email),
|
||||||
"-t",
|
"-t",
|
||||||
"pvincent@comptoirduvrac.re",
|
to,
|
||||||
// "-bcc", "pvincent974@gmail.com,pvincent974@laposte.net",
|
"-bcc",
|
||||||
|
bcc,
|
||||||
"-u",
|
"-u",
|
||||||
e.getSubject(),
|
e.getSubject(),
|
||||||
"-m",
|
"-m",
|
||||||
"alors tout va bien",
|
'<html>${e.getHtmlBody()}</html>',
|
||||||
"-xu",
|
|
||||||
"postmaster@comptoirduvrac.re",
|
|
||||||
"-xp",
|
|
||||||
"QqQeAPT6EpoK"
|
|
||||||
];
|
];
|
||||||
|
|
||||||
App.log('args=${args.join(" ")}');
|
// if (App.config.DEBUG)
|
||||||
|
// App.log('args=${args.join(" ")}');
|
||||||
|
|
||||||
var exitCode = Sys.command("sendemail", args);
|
var exitCode = Sys.command("sendemail", args);
|
||||||
// var exitCode = 0;
|
// var exitCode = 0;
|
||||||
|
|
||||||
|
var summary = 'email from="${fromString(e.getSender().name, e.getSender().email)}"> subject=<${e.getSubject()}>';
|
||||||
if (exitCode == 0)
|
if (exitCode == 0)
|
||||||
App.log('email from="${e.getSender().name} <${e.getSender().email}"> subject=<${e.getSubject()}> successfully sent');
|
App.log('$summary successfully sent');
|
||||||
else
|
else
|
||||||
App.log('ERROR: email from="${e.getSender().name} <${e.getSender().email}"> subject=<${e.getSubject()}> cannot be sent');
|
App.log('ERROR: $summary cannot be sent, please review logs');
|
||||||
|
|
||||||
// sys.io.File.saveContent('/tmp/my_file.json', "CONTENT");
|
|
||||||
|
|
||||||
// var surprise = m.send({
|
|
||||||
// subject: e.getSubject(),
|
|
||||||
// from: new Address({address: e.getSender().email}),
|
|
||||||
// to: Lambda.array(Lambda.map(e.getRecipients(), function(x) return new Address({address: x.email}))),
|
|
||||||
// headers: e.getHeaders(),
|
|
||||||
// content: {
|
|
||||||
// text: e.getTextBody(),
|
|
||||||
// html: e.getHtmlBody()
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
var map = new MailerResult();
|
var map = new MailerResult();
|
||||||
|
|||||||
Reference in New Issue
Block a user