From 13486a5ada62e4355473ca01e07371c162951e84 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Thu, 12 Feb 2015 13:53:27 +0100 Subject: Migrate to SwiftMail Replaces the OC_Mail and phpmailer with SwiftMail allowing us to mock it properly. Fixes the unit test execution on master on local machines and https://github.com/owncloud/core/issues/12014 Conflicts: 3rdparty lib/private/server.php lib/public/iservercontainer.php tests/lib/mail.php tests/settings/controller/mailsettingscontrollertest.php Conflicts: 3rdparty lib/private/mail.php lib/private/server.php lib/public/iservercontainer.php settings/ajax/lostpassword.php settings/application.php --- lib/public/util.php | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'lib/public/util.php') diff --git a/lib/public/util.php b/lib/public/util.php index aa6cd5ba012..71ab8cabce5 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -63,12 +63,31 @@ class Util { * @param string $ccaddress * @param string $ccname * @param string $bcc + * @deprecated Use \OCP\Mail\IMailer instead */ public static function sendMail( $toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, $html = 0, $altbody = '', $ccaddress = '', $ccname = '', $bcc = '') { - // call the internal mail class - \OC_MAIL::send($toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, - $html, $altbody, $ccaddress, $ccname, $bcc); + $mailer = \OC::$server->getMailer(); + $message = $mailer->createMessage(); + $message->setTo(array($toaddress => $toname)); + $message->setSubject($subject); + $message->setPlainBody($mailtext); + $message->setFrom(array($fromaddress => $fromname)); + if($html === 1) { + $message->setHTMLBody($altbody); + } + if(!empty($ccaddress)) { + if(!empty($ccname)) { + $message->setCc(array($ccaddress => $ccname)); + } else { + $message->setCc(array($ccaddress)); + } + } + if(!empty($bcc)) { + $message->setBcc(array($bcc)); + } + + $mailer->send($message); } /** @@ -275,7 +294,7 @@ class Util { $host_name = \OC_Config::getValue('mail_domain', $host_name); $defaultEmailAddress = $user_part.'@'.$host_name; - if (\OC_Mail::validateAddress($defaultEmailAddress)) { + if (\OCP\Mail\Util::validateMailAddress($defaultEmailAddress)) { return $defaultEmailAddress; } -- cgit v1.2.3