|
@ -40,53 +40,62 @@ class SendEmailMailer implements IMailer { |
|
|
return mailer; |
|
|
return mailer; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private function fromString(name:String, email:String) { |
|
|
|
|
|
return (name == null) ? email : '${name} <${email}>'; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public function send(e:sugoi.mail.IMail, ?params:Dynamic, ?callback:MailerResult->Void) { |
|
|
public function send(e:sugoi.mail.IMail, ?params:Dynamic, ?callback:MailerResult->Void) { |
|
|
var mailServer = "mail1.zourit.net"; |
|
|
|
|
|
var mailPort = 587; |
|
|
|
|
|
|
|
|
var to:String; |
|
|
|
|
|
var bcc:String; |
|
|
|
|
|
|
|
|
var fromName = "John Doe"; |
|
|
|
|
|
var fromEmail = "no-reply@comptoirduvrac.re"; |
|
|
|
|
|
|
|
|
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", |
|
|
|
|
|
'${fromName} <${fromEmail}>', |
|
|
|
|
|
|
|
|
// arguments |
|
|
"-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", |
|
|
|
|
|
// "-bcc", "pvincent974@gmail.com,pvincent974@laposte.net", |
|
|
|
|
|
|
|
|
to, |
|
|
|
|
|
"-bcc", |
|
|
|
|
|
bcc, |
|
|
"-u", |
|
|
"-u", |
|
|
e.getSubject(), |
|
|
e.getSubject(), |
|
|
"-m", |
|
|
"-m", |
|
|
"alors tout va bien", |
|
|
|
|
|
"-xu", |
|
|
|
|
|
"postmaster@comptoirduvrac.re", |
|
|
|
|
|
"-xp", |
|
|
|
|
|
"QqQeAPT6EpoK" |
|
|
|
|
|
|
|
|
'<html>${e.getHtmlBody()}</html>', |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
|
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'); |
|
|
|
|
|
|
|
|
|
|
|
// 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() |
|
|
|
|
|
// } |
|
|
|
|
|
// }); |
|
|
|
|
|
|
|
|
App.log('ERROR: $summary cannot be sent, please review logs'); |
|
|
|
|
|
|
|
|
if (callback != null) { |
|
|
if (callback != null) { |
|
|
var map = new MailerResult(); |
|
|
var map = new MailerResult(); |
|
|