aboutsummaryrefslogtreecommitdiffstats
path: root/includes/mail/Emailer.php
diff options
context:
space:
mode:
authorPeter Ovchyn <peter.ovchyn@speedandfunction.com>2020-03-09 13:00:28 +0200
committerPeter Ovchyn <peter.ovchyn@speedandfunction.com>2020-03-17 21:41:34 +0200
commit176531d8c706b0c167ae6dedf6de34a80d779e24 (patch)
treea989471ac99745aa70cf2882549fbda355d71488 /includes/mail/Emailer.php
parentff7bdd36e072be70012a8a89e5a77d6cca2cfc57 (diff)
downloadmediawikicore-176531d8c706b0c167ae6dedf6de34a80d779e24.tar.gz
mediawikicore-176531d8c706b0c167ae6dedf6de34a80d779e24.zip
Introduce Emailer as service
In order to test functionality dependant on sending emails Emailer should be introduced as service Bug: T247229 Change-Id: I4fcceb7860a9a4dda091fb4cffcd2f6950fffaf8
Diffstat (limited to 'includes/mail/Emailer.php')
-rw-r--r--includes/mail/Emailer.php54
1 files changed, 54 insertions, 0 deletions
diff --git a/includes/mail/Emailer.php b/includes/mail/Emailer.php
new file mode 100644
index 000000000000..de762cfa8a0e
--- /dev/null
+++ b/includes/mail/Emailer.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ */
+
+namespace MediaWiki\Mail;
+
+use MailAddress;
+use StatusValue;
+use UserMailer;
+
+/**
+ * @internal
+ * @since 1.35
+ */
+class Emailer implements IEmailer {
+
+ /**
+ * @since 1.35
+ *
+ * This function will perform a direct (authenticated) login to
+ * a SMTP Server to use for mail relaying if 'wgSMTP' specifies an
+ * array of parameters. It requires PEAR:Mail to do that.
+ * Otherwise it just uses the standard PHP 'mail' function.
+ *
+ * @inheritDoc
+ */
+ public function send(
+ array $to,
+ MailAddress $from,
+ string $subject,
+ string $bodyText,
+ ?string $bodyHtml = null,
+ array $options = []
+ ): StatusValue {
+ $body = $bodyHtml ? [ 'text' => $bodyText, 'html' => $bodyHtml ] : $bodyText;
+ return UserMailer::send( $to, $from, $subject, $body, $options );
+ }
+}