summaryrefslogtreecommitdiffstats
path: root/lib/public/util.php
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2015-02-12 13:53:27 +0100
committerLukas Reschke <lukas@owncloud.com>2015-03-16 12:47:05 +0100
commit13486a5ada62e4355473ca01e07371c162951e84 (patch)
treec079e9c53691ca14e5e1898c40a93322d6e727f5 /lib/public/util.php
parent0d9f149dd93997085b85e2b174f5989a1b996263 (diff)
downloadnextcloud-server-13486a5ada62e4355473ca01e07371c162951e84.tar.gz
nextcloud-server-13486a5ada62e4355473ca01e07371c162951e84.zip
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
Diffstat (limited to 'lib/public/util.php')
-rw-r--r--lib/public/util.php27
1 files changed, 23 insertions, 4 deletions
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;
}