Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Switch lite version to full version
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Jan 17, 2017
1 parent 85c6572 commit 597a6f7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2,168 deletions.
22 changes: 12 additions & 10 deletions core/src/plugins/mailer.phpmailer-lite/PhpMailLite.php
Expand Up @@ -22,8 +22,8 @@
namespace Pydio\Mailer\Implementation;

use Exception;
use PHPMailer;
use phpmailerException;
use PHPMailerLite;
use Pydio\Core\Model\Context;
use Pydio\Core\Model\ContextInterface;
use Pydio\Mailer\Core\Mailer;
Expand All @@ -50,13 +50,15 @@ class PhpMailLite extends Mailer
*/
protected function sendMailImpl(ContextInterface $ctx, $recipients, $subject, $body, $from = null, $images = array(), $useHtml = true)
{
require_once("lib/class.phpmailer-lite.php");
require_once("vendor/autoload.php");
$realRecipients = $this->resolveAdresses($ctx, $recipients);
if(!count($realRecipients)){
return;
}
// NOW IF THERE ARE RECIPIENTS FOR ANY REASON, GO
$mail = new PHPMailerLite(true);
$mail = new PHPMailer(true);

//All option are set in the PHPMailer class
$mail->Mailer = $this->getContextualOption(Context::emptyContext(), "MAILER");
$mail->Sendmail = $this->getContextualOption(Context::emptyContext(), "SENDMAIL_PATH");
$from = $this->resolveFrom($ctx, $from);
Expand All @@ -65,24 +67,24 @@ protected function sendMailImpl(ContextInterface $ctx, $recipients, $subject, $b
}
if (!empty($from)) {
if ($from["adress"] != $from["name"]) {
$mail->SetFrom($from["adress"], $from["name"]);
$mail->setFrom($from["adress"], $from["name"]);
} else {
$mail->SetFrom($from["adress"]);
$mail->setFrom($from["adress"]);
}
}
foreach ($realRecipients as $address) {
if ($address["adress"] == $address["name"]) {
$mail->AddAddress(trim($address["adress"]));
$mail->addAddress(trim($address["adress"]));
} else {
$mail->AddAddress(trim($address["adress"]), trim($address["name"]));
$mail->addAddress(trim($address["adress"]), trim($address["name"]));
}
}
$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->IsHTML($useHtml); // set email format to HTML
$mail->isHTML($useHtml); // set email format to HTML
$mail->CharSet = "utf-8";
$mail->Encoding = $this->getContextualOption(Context::emptyContext(), "MAIL_ENCODING");
foreach ($images as $image) {
$mail->AddEmbeddedImage($image["path"], $image["cid"], '', 'base64', 'image/png');
$mail->addEmbeddedImage($image["path"], $image["cid"], '', 'base64', 'image/png');
}

$mail->Subject = $subject;
Expand All @@ -97,7 +99,7 @@ protected function sendMailImpl(ContextInterface $ctx, $recipients, $subject, $b
$mail->Body = Mailer::simpleHtml2Text($body);
}

if (!$mail->Send()) {
if (!$mail->send()) {
$message = "Message could not be sent\n";
$message .= "Mailer Error: " . $mail->ErrorInfo;
throw new Exception($message);
Expand Down
5 changes: 5 additions & 0 deletions core/src/plugins/mailer.phpmailer-lite/composer.json
@@ -0,0 +1,5 @@
{
"require": {
"phpmailer/phpmailer": "v5.2.22"
}
}

0 comments on commit 597a6f7

Please sign in to comment.