Completed
Pull Request — master (#9205)
by Morris
42:49 queued 22:40
created
lib/private/Mail/Message.php 1 patch
Indentation   +247 added lines, -247 removed lines patch added patch discarded remove patch
@@ -37,251 +37,251 @@
 block discarded – undo
37 37
  * @package OC\Mail
38 38
  */
39 39
 class Message implements IMessage {
40
-	/** @var Swift_Message */
41
-	private $swiftMessage;
42
-	/** @var bool */
43
-	private $plainTextOnly;
44
-
45
-	public function __construct(Swift_Message $swiftMessage, bool $plainTextOnly) {
46
-		$this->swiftMessage = $swiftMessage;
47
-		$this->plainTextOnly = $plainTextOnly;
48
-	}
49
-
50
-	/**
51
-	 * @param IAttachment $attachment
52
-	 * @return $this
53
-	 * @since 13.0.0
54
-	 */
55
-	public function attach(IAttachment $attachment): IMessage {
56
-		/** @var Attachment $attachment */
57
-		$this->swiftMessage->attach($attachment->getSwiftAttachment());
58
-		return $this;
59
-	}
60
-
61
-	/**
62
-	 * SwiftMailer does currently not work with IDN domains, this function therefore converts the domains
63
-	 * FIXME: Remove this once SwiftMailer supports IDN
64
-	 *
65
-	 * @param array $addresses Array of mail addresses, key will get converted
66
-	 * @return array Converted addresses if `idn_to_ascii` exists
67
-	 */
68
-	protected function convertAddresses(array $addresses): array {
69
-		if (!function_exists('idn_to_ascii') || !defined('INTL_IDNA_VARIANT_UTS46')) {
70
-			return $addresses;
71
-		}
72
-
73
-		$convertedAddresses = [];
74
-
75
-		foreach($addresses as $email => $readableName) {
76
-			if(!is_numeric($email)) {
77
-				list($name, $domain) = explode('@', $email, 2);
78
-				$domain = idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46);
79
-				$convertedAddresses[$name.'@'.$domain] = $readableName;
80
-			} else {
81
-				list($name, $domain) = explode('@', $readableName, 2);
82
-				$domain = idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46);
83
-				$convertedAddresses[$email] = $name.'@'.$domain;
84
-			}
85
-		}
86
-
87
-		return $convertedAddresses;
88
-	}
89
-
90
-	/**
91
-	 * Set the from address of this message.
92
-	 *
93
-	 * If no "From" address is used \OC\Mail\Mailer will use mail_from_address and mail_domain from config.php
94
-	 *
95
-	 * @param array $addresses Example: array('[email protected]', '[email protected]' => 'A name')
96
-	 * @return $this
97
-	 */
98
-	public function setFrom(array $addresses): IMessage {
99
-		$addresses = $this->convertAddresses($addresses);
100
-
101
-		$this->swiftMessage->setFrom($addresses);
102
-		return $this;
103
-	}
104
-
105
-	/**
106
-	 * Get the from address of this message.
107
-	 *
108
-	 * @return array
109
-	 */
110
-	public function getFrom(): array {
111
-		return $this->swiftMessage->getFrom();
112
-	}
113
-
114
-	/**
115
-	 * Set the Reply-To address of this message
116
-	 *
117
-	 * @param array $addresses
118
-	 * @return $this
119
-	 */
120
-	public function setReplyTo(array $addresses): IMessage {
121
-		$addresses = $this->convertAddresses($addresses);
122
-
123
-		$this->swiftMessage->setReplyTo($addresses);
124
-		return $this;
125
-	}
126
-
127
-	/**
128
-	 * Returns the Reply-To address of this message
129
-	 *
130
-	 * @return string
131
-	 */
132
-	public function getReplyTo(): string {
133
-		return $this->swiftMessage->getReplyTo();
134
-	}
135
-
136
-	/**
137
-	 * Set the to addresses of this message.
138
-	 *
139
-	 * @param array $recipients Example: array('[email protected]', '[email protected]' => 'A name')
140
-	 * @return $this
141
-	 */
142
-	public function setTo(array $recipients): IMessage {
143
-		$recipients = $this->convertAddresses($recipients);
144
-
145
-		$this->swiftMessage->setTo($recipients);
146
-		return $this;
147
-	}
148
-
149
-	/**
150
-	 * Get the to address of this message.
151
-	 *
152
-	 * @return array
153
-	 */
154
-	public function getTo(): array {
155
-		return $this->swiftMessage->getTo();
156
-	}
157
-
158
-	/**
159
-	 * Set the CC recipients of this message.
160
-	 *
161
-	 * @param array $recipients Example: array('[email protected]', '[email protected]' => 'A name')
162
-	 * @return $this
163
-	 */
164
-	public function setCc(array $recipients): IMessage {
165
-		$recipients = $this->convertAddresses($recipients);
166
-
167
-		$this->swiftMessage->setCc($recipients);
168
-		return $this;
169
-	}
170
-
171
-	/**
172
-	 * Get the cc address of this message.
173
-	 *
174
-	 * @return array
175
-	 */
176
-	public function getCc(): array {
177
-		return $this->swiftMessage->getCc();
178
-	}
179
-
180
-	/**
181
-	 * Set the BCC recipients of this message.
182
-	 *
183
-	 * @param array $recipients Example: array('[email protected]', '[email protected]' => 'A name')
184
-	 * @return $this
185
-	 */
186
-	public function setBcc(array $recipients): IMessage {
187
-		$recipients = $this->convertAddresses($recipients);
188
-
189
-		$this->swiftMessage->setBcc($recipients);
190
-		return $this;
191
-	}
192
-
193
-	/**
194
-	 * Get the Bcc address of this message.
195
-	 *
196
-	 * @return array
197
-	 */
198
-	public function getBcc(): array {
199
-		return $this->swiftMessage->getBcc();
200
-	}
201
-
202
-	/**
203
-	 * Set the subject of this message.
204
-	 *
205
-	 * @param string $subject
206
-	 * @return IMessage
207
-	 */
208
-	public function setSubject(string $subject): IMessage {
209
-		$this->swiftMessage->setSubject($subject);
210
-		return $this;
211
-	}
212
-
213
-	/**
214
-	 * Get the from subject of this message.
215
-	 *
216
-	 * @return string
217
-	 */
218
-	public function getSubject(): string {
219
-		return $this->swiftMessage->getSubject();
220
-	}
221
-
222
-	/**
223
-	 * Set the plain-text body of this message.
224
-	 *
225
-	 * @param string $body
226
-	 * @return $this
227
-	 */
228
-	public function setPlainBody(string $body): IMessage {
229
-		$this->swiftMessage->setBody($body);
230
-		return $this;
231
-	}
232
-
233
-	/**
234
-	 * Get the plain body of this message.
235
-	 *
236
-	 * @return string
237
-	 */
238
-	public function getPlainBody(): string {
239
-		return $this->swiftMessage->getBody();
240
-	}
241
-
242
-	/**
243
-	 * Set the HTML body of this message. Consider also sending a plain-text body instead of only an HTML one.
244
-	 *
245
-	 * @param string $body
246
-	 * @return $this
247
-	 */
248
-	public function setHtmlBody($body) {
249
-		if (!$this->plainTextOnly) {
250
-			$this->swiftMessage->addPart($body, 'text/html');
251
-		}
252
-		return $this;
253
-	}
254
-
255
-	/**
256
-	 * Get's the underlying SwiftMessage
257
-	 * @return Swift_Message
258
-	 */
259
-	public function getSwiftMessage(): Swift_Message {
260
-		return $this->swiftMessage;
261
-	}
262
-
263
-	/**
264
-	 * @param string $body
265
-	 * @param string $contentType
266
-	 * @return $this
267
-	 */
268
-	public function setBody($body, $contentType) {
269
-		if (!$this->plainTextOnly || $contentType !== 'text/html') {
270
-			$this->swiftMessage->setBody($body, $contentType);
271
-		}
272
-		return $this;
273
-	}
274
-
275
-	/**
276
-	 * @param IEMailTemplate $emailTemplate
277
-	 * @return $this
278
-	 */
279
-	public function useTemplate(IEMailTemplate $emailTemplate): IMessage {
280
-		$this->setSubject($emailTemplate->renderSubject());
281
-		$this->setPlainBody($emailTemplate->renderText());
282
-		if (!$this->plainTextOnly) {
283
-			$this->setHtmlBody($emailTemplate->renderHtml());
284
-		}
285
-		return $this;
286
-	}
40
+    /** @var Swift_Message */
41
+    private $swiftMessage;
42
+    /** @var bool */
43
+    private $plainTextOnly;
44
+
45
+    public function __construct(Swift_Message $swiftMessage, bool $plainTextOnly) {
46
+        $this->swiftMessage = $swiftMessage;
47
+        $this->plainTextOnly = $plainTextOnly;
48
+    }
49
+
50
+    /**
51
+     * @param IAttachment $attachment
52
+     * @return $this
53
+     * @since 13.0.0
54
+     */
55
+    public function attach(IAttachment $attachment): IMessage {
56
+        /** @var Attachment $attachment */
57
+        $this->swiftMessage->attach($attachment->getSwiftAttachment());
58
+        return $this;
59
+    }
60
+
61
+    /**
62
+     * SwiftMailer does currently not work with IDN domains, this function therefore converts the domains
63
+     * FIXME: Remove this once SwiftMailer supports IDN
64
+     *
65
+     * @param array $addresses Array of mail addresses, key will get converted
66
+     * @return array Converted addresses if `idn_to_ascii` exists
67
+     */
68
+    protected function convertAddresses(array $addresses): array {
69
+        if (!function_exists('idn_to_ascii') || !defined('INTL_IDNA_VARIANT_UTS46')) {
70
+            return $addresses;
71
+        }
72
+
73
+        $convertedAddresses = [];
74
+
75
+        foreach($addresses as $email => $readableName) {
76
+            if(!is_numeric($email)) {
77
+                list($name, $domain) = explode('@', $email, 2);
78
+                $domain = idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46);
79
+                $convertedAddresses[$name.'@'.$domain] = $readableName;
80
+            } else {
81
+                list($name, $domain) = explode('@', $readableName, 2);
82
+                $domain = idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46);
83
+                $convertedAddresses[$email] = $name.'@'.$domain;
84
+            }
85
+        }
86
+
87
+        return $convertedAddresses;
88
+    }
89
+
90
+    /**
91
+     * Set the from address of this message.
92
+     *
93
+     * If no "From" address is used \OC\Mail\Mailer will use mail_from_address and mail_domain from config.php
94
+     *
95
+     * @param array $addresses Example: array('[email protected]', '[email protected]' => 'A name')
96
+     * @return $this
97
+     */
98
+    public function setFrom(array $addresses): IMessage {
99
+        $addresses = $this->convertAddresses($addresses);
100
+
101
+        $this->swiftMessage->setFrom($addresses);
102
+        return $this;
103
+    }
104
+
105
+    /**
106
+     * Get the from address of this message.
107
+     *
108
+     * @return array
109
+     */
110
+    public function getFrom(): array {
111
+        return $this->swiftMessage->getFrom();
112
+    }
113
+
114
+    /**
115
+     * Set the Reply-To address of this message
116
+     *
117
+     * @param array $addresses
118
+     * @return $this
119
+     */
120
+    public function setReplyTo(array $addresses): IMessage {
121
+        $addresses = $this->convertAddresses($addresses);
122
+
123
+        $this->swiftMessage->setReplyTo($addresses);
124
+        return $this;
125
+    }
126
+
127
+    /**
128
+     * Returns the Reply-To address of this message
129
+     *
130
+     * @return string
131
+     */
132
+    public function getReplyTo(): string {
133
+        return $this->swiftMessage->getReplyTo();
134
+    }
135
+
136
+    /**
137
+     * Set the to addresses of this message.
138
+     *
139
+     * @param array $recipients Example: array('[email protected]', '[email protected]' => 'A name')
140
+     * @return $this
141
+     */
142
+    public function setTo(array $recipients): IMessage {
143
+        $recipients = $this->convertAddresses($recipients);
144
+
145
+        $this->swiftMessage->setTo($recipients);
146
+        return $this;
147
+    }
148
+
149
+    /**
150
+     * Get the to address of this message.
151
+     *
152
+     * @return array
153
+     */
154
+    public function getTo(): array {
155
+        return $this->swiftMessage->getTo();
156
+    }
157
+
158
+    /**
159
+     * Set the CC recipients of this message.
160
+     *
161
+     * @param array $recipients Example: array('[email protected]', '[email protected]' => 'A name')
162
+     * @return $this
163
+     */
164
+    public function setCc(array $recipients): IMessage {
165
+        $recipients = $this->convertAddresses($recipients);
166
+
167
+        $this->swiftMessage->setCc($recipients);
168
+        return $this;
169
+    }
170
+
171
+    /**
172
+     * Get the cc address of this message.
173
+     *
174
+     * @return array
175
+     */
176
+    public function getCc(): array {
177
+        return $this->swiftMessage->getCc();
178
+    }
179
+
180
+    /**
181
+     * Set the BCC recipients of this message.
182
+     *
183
+     * @param array $recipients Example: array('[email protected]', '[email protected]' => 'A name')
184
+     * @return $this
185
+     */
186
+    public function setBcc(array $recipients): IMessage {
187
+        $recipients = $this->convertAddresses($recipients);
188
+
189
+        $this->swiftMessage->setBcc($recipients);
190
+        return $this;
191
+    }
192
+
193
+    /**
194
+     * Get the Bcc address of this message.
195
+     *
196
+     * @return array
197
+     */
198
+    public function getBcc(): array {
199
+        return $this->swiftMessage->getBcc();
200
+    }
201
+
202
+    /**
203
+     * Set the subject of this message.
204
+     *
205
+     * @param string $subject
206
+     * @return IMessage
207
+     */
208
+    public function setSubject(string $subject): IMessage {
209
+        $this->swiftMessage->setSubject($subject);
210
+        return $this;
211
+    }
212
+
213
+    /**
214
+     * Get the from subject of this message.
215
+     *
216
+     * @return string
217
+     */
218
+    public function getSubject(): string {
219
+        return $this->swiftMessage->getSubject();
220
+    }
221
+
222
+    /**
223
+     * Set the plain-text body of this message.
224
+     *
225
+     * @param string $body
226
+     * @return $this
227
+     */
228
+    public function setPlainBody(string $body): IMessage {
229
+        $this->swiftMessage->setBody($body);
230
+        return $this;
231
+    }
232
+
233
+    /**
234
+     * Get the plain body of this message.
235
+     *
236
+     * @return string
237
+     */
238
+    public function getPlainBody(): string {
239
+        return $this->swiftMessage->getBody();
240
+    }
241
+
242
+    /**
243
+     * Set the HTML body of this message. Consider also sending a plain-text body instead of only an HTML one.
244
+     *
245
+     * @param string $body
246
+     * @return $this
247
+     */
248
+    public function setHtmlBody($body) {
249
+        if (!$this->plainTextOnly) {
250
+            $this->swiftMessage->addPart($body, 'text/html');
251
+        }
252
+        return $this;
253
+    }
254
+
255
+    /**
256
+     * Get's the underlying SwiftMessage
257
+     * @return Swift_Message
258
+     */
259
+    public function getSwiftMessage(): Swift_Message {
260
+        return $this->swiftMessage;
261
+    }
262
+
263
+    /**
264
+     * @param string $body
265
+     * @param string $contentType
266
+     * @return $this
267
+     */
268
+    public function setBody($body, $contentType) {
269
+        if (!$this->plainTextOnly || $contentType !== 'text/html') {
270
+            $this->swiftMessage->setBody($body, $contentType);
271
+        }
272
+        return $this;
273
+    }
274
+
275
+    /**
276
+     * @param IEMailTemplate $emailTemplate
277
+     * @return $this
278
+     */
279
+    public function useTemplate(IEMailTemplate $emailTemplate): IMessage {
280
+        $this->setSubject($emailTemplate->renderSubject());
281
+        $this->setPlainBody($emailTemplate->renderText());
282
+        if (!$this->plainTextOnly) {
283
+            $this->setHtmlBody($emailTemplate->renderHtml());
284
+        }
285
+        return $this;
286
+    }
287 287
 }
Please login to merge, or discard this patch.
lib/private/Mail/Mailer.php 1 patch
Indentation   +212 added lines, -212 removed lines patch added patch discarded remove patch
@@ -55,242 +55,242 @@
 block discarded – undo
55 55
  * @package OC\Mail
56 56
  */
57 57
 class Mailer implements IMailer {
58
-	/** @var \Swift_SmtpTransport|\Swift_SendmailTransport|\Swift_MailTransport Cached transport */
59
-	private $instance = null;
60
-	/** @var IConfig */
61
-	private $config;
62
-	/** @var ILogger */
63
-	private $logger;
64
-	/** @var Defaults */
65
-	private $defaults;
66
-	/** @var IURLGenerator */
67
-	private $urlGenerator;
68
-	/** @var IL10N */
69
-	private $l10n;
58
+    /** @var \Swift_SmtpTransport|\Swift_SendmailTransport|\Swift_MailTransport Cached transport */
59
+    private $instance = null;
60
+    /** @var IConfig */
61
+    private $config;
62
+    /** @var ILogger */
63
+    private $logger;
64
+    /** @var Defaults */
65
+    private $defaults;
66
+    /** @var IURLGenerator */
67
+    private $urlGenerator;
68
+    /** @var IL10N */
69
+    private $l10n;
70 70
 
71
-	/**
72
-	 * @param IConfig $config
73
-	 * @param ILogger $logger
74
-	 * @param Defaults $defaults
75
-	 * @param IURLGenerator $urlGenerator
76
-	 * @param IL10N $l10n
77
-	 */
78
-	public function __construct(IConfig $config,
79
-						 ILogger $logger,
80
-						 Defaults $defaults,
81
-						 IURLGenerator $urlGenerator,
82
-						 IL10N $l10n) {
83
-		$this->config = $config;
84
-		$this->logger = $logger;
85
-		$this->defaults = $defaults;
86
-		$this->urlGenerator = $urlGenerator;
87
-		$this->l10n = $l10n;
88
-	}
71
+    /**
72
+     * @param IConfig $config
73
+     * @param ILogger $logger
74
+     * @param Defaults $defaults
75
+     * @param IURLGenerator $urlGenerator
76
+     * @param IL10N $l10n
77
+     */
78
+    public function __construct(IConfig $config,
79
+                            ILogger $logger,
80
+                            Defaults $defaults,
81
+                            IURLGenerator $urlGenerator,
82
+                            IL10N $l10n) {
83
+        $this->config = $config;
84
+        $this->logger = $logger;
85
+        $this->defaults = $defaults;
86
+        $this->urlGenerator = $urlGenerator;
87
+        $this->l10n = $l10n;
88
+    }
89 89
 
90
-	/**
91
-	 * Creates a new message object that can be passed to send()
92
-	 *
93
-	 * @return IMessage
94
-	 */
95
-	public function createMessage(): IMessage {
96
-		$plainTextOnly = $this->config->getSystemValue('mail_send_plaintext_only', false);
97
-		return new Message(new \Swift_Message(), $plainTextOnly);
98
-	}
90
+    /**
91
+     * Creates a new message object that can be passed to send()
92
+     *
93
+     * @return IMessage
94
+     */
95
+    public function createMessage(): IMessage {
96
+        $plainTextOnly = $this->config->getSystemValue('mail_send_plaintext_only', false);
97
+        return new Message(new \Swift_Message(), $plainTextOnly);
98
+    }
99 99
 
100
-	/**
101
-	 * @param string|null $data
102
-	 * @param string|null $filename
103
-	 * @param string|null $contentType
104
-	 * @return IAttachment
105
-	 * @since 13.0.0
106
-	 */
107
-	public function createAttachment($data = null, $filename = null, $contentType = null): IAttachment {
108
-		return new Attachment(\Swift_Attachment::newInstance($data, $filename, $contentType));
109
-	}
100
+    /**
101
+     * @param string|null $data
102
+     * @param string|null $filename
103
+     * @param string|null $contentType
104
+     * @return IAttachment
105
+     * @since 13.0.0
106
+     */
107
+    public function createAttachment($data = null, $filename = null, $contentType = null): IAttachment {
108
+        return new Attachment(\Swift_Attachment::newInstance($data, $filename, $contentType));
109
+    }
110 110
 
111
-	/**
112
-	 * @param string $path
113
-	 * @param string|null $contentType
114
-	 * @return IAttachment
115
-	 * @since 13.0.0
116
-	 */
117
-	public function createAttachmentFromPath(string $path, $contentType = null): IAttachment {
118
-		return new Attachment(\Swift_Attachment::fromPath($path, $contentType));
119
-	}
111
+    /**
112
+     * @param string $path
113
+     * @param string|null $contentType
114
+     * @return IAttachment
115
+     * @since 13.0.0
116
+     */
117
+    public function createAttachmentFromPath(string $path, $contentType = null): IAttachment {
118
+        return new Attachment(\Swift_Attachment::fromPath($path, $contentType));
119
+    }
120 120
 
121
-	/**
122
-	 * Creates a new email template object
123
-	 *
124
-	 * @param string $emailId
125
-	 * @param array $data
126
-	 * @return IEMailTemplate
127
-	 * @since 12.0.0
128
-	 */
129
-	public function createEMailTemplate(string $emailId, array $data = []): IEMailTemplate {
130
-		$class = $this->config->getSystemValue('mail_template_class', '');
121
+    /**
122
+     * Creates a new email template object
123
+     *
124
+     * @param string $emailId
125
+     * @param array $data
126
+     * @return IEMailTemplate
127
+     * @since 12.0.0
128
+     */
129
+    public function createEMailTemplate(string $emailId, array $data = []): IEMailTemplate {
130
+        $class = $this->config->getSystemValue('mail_template_class', '');
131 131
 
132
-		if ($class !== '' && class_exists($class) && is_a($class, EMailTemplate::class, true)) {
133
-			return new $class(
134
-				$this->defaults,
135
-				$this->urlGenerator,
136
-				$this->l10n,
137
-				$emailId,
138
-				$data
139
-			);
140
-		}
132
+        if ($class !== '' && class_exists($class) && is_a($class, EMailTemplate::class, true)) {
133
+            return new $class(
134
+                $this->defaults,
135
+                $this->urlGenerator,
136
+                $this->l10n,
137
+                $emailId,
138
+                $data
139
+            );
140
+        }
141 141
 
142
-		return new EMailTemplate(
143
-			$this->defaults,
144
-			$this->urlGenerator,
145
-			$this->l10n,
146
-			$emailId,
147
-			$data
148
-		);
149
-	}
142
+        return new EMailTemplate(
143
+            $this->defaults,
144
+            $this->urlGenerator,
145
+            $this->l10n,
146
+            $emailId,
147
+            $data
148
+        );
149
+    }
150 150
 
151
-	/**
152
-	 * Send the specified message. Also sets the from address to the value defined in config.php
153
-	 * if no-one has been passed.
154
-	 *
155
-	 * @param IMessage|Message $message Message to send
156
-	 * @return string[] Array with failed recipients. Be aware that this depends on the used mail backend and
157
-	 * therefore should be considered
158
-	 * @throws \Exception In case it was not possible to send the message. (for example if an invalid mail address
159
-	 * has been supplied.)
160
-	 */
161
-	public function send(IMessage $message): array {
162
-		$debugMode = $this->config->getSystemValue('mail_smtpdebug', false);
151
+    /**
152
+     * Send the specified message. Also sets the from address to the value defined in config.php
153
+     * if no-one has been passed.
154
+     *
155
+     * @param IMessage|Message $message Message to send
156
+     * @return string[] Array with failed recipients. Be aware that this depends on the used mail backend and
157
+     * therefore should be considered
158
+     * @throws \Exception In case it was not possible to send the message. (for example if an invalid mail address
159
+     * has been supplied.)
160
+     */
161
+    public function send(IMessage $message): array {
162
+        $debugMode = $this->config->getSystemValue('mail_smtpdebug', false);
163 163
 
164
-		if (empty($message->getFrom())) {
165
-			$message->setFrom([\OCP\Util::getDefaultEmailAddress($this->defaults->getName()) => $this->defaults->getName()]);
166
-		}
164
+        if (empty($message->getFrom())) {
165
+            $message->setFrom([\OCP\Util::getDefaultEmailAddress($this->defaults->getName()) => $this->defaults->getName()]);
166
+        }
167 167
 
168
-		$failedRecipients = [];
168
+        $failedRecipients = [];
169 169
 
170
-		$mailer = $this->getInstance();
170
+        $mailer = $this->getInstance();
171 171
 
172
-		// Enable logger if debug mode is enabled
173
-		if($debugMode) {
174
-			$mailLogger = new \Swift_Plugins_Loggers_ArrayLogger();
175
-			$mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($mailLogger));
176
-		}
172
+        // Enable logger if debug mode is enabled
173
+        if($debugMode) {
174
+            $mailLogger = new \Swift_Plugins_Loggers_ArrayLogger();
175
+            $mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($mailLogger));
176
+        }
177 177
 
178
-		$mailer->send($message->getSwiftMessage(), $failedRecipients);
178
+        $mailer->send($message->getSwiftMessage(), $failedRecipients);
179 179
 
180
-		// Debugging logging
181
-		$logMessage = sprintf('Sent mail to "%s" with subject "%s"', print_r($message->getTo(), true), $message->getSubject());
182
-		$this->logger->debug($logMessage, ['app' => 'core']);
183
-		if($debugMode && isset($mailLogger)) {
184
-			$this->logger->debug($mailLogger->dump(), ['app' => 'core']);
185
-		}
180
+        // Debugging logging
181
+        $logMessage = sprintf('Sent mail to "%s" with subject "%s"', print_r($message->getTo(), true), $message->getSubject());
182
+        $this->logger->debug($logMessage, ['app' => 'core']);
183
+        if($debugMode && isset($mailLogger)) {
184
+            $this->logger->debug($mailLogger->dump(), ['app' => 'core']);
185
+        }
186 186
 
187
-		return $failedRecipients;
188
-	}
187
+        return $failedRecipients;
188
+    }
189 189
 
190
-	/**
191
-	 * Checks if an e-mail address is valid
192
-	 *
193
-	 * @param string $email Email address to be validated
194
-	 * @return bool True if the mail address is valid, false otherwise
195
-	 */
196
-	public function validateMailAddress(string $email): bool {
197
-		return \Swift_Validate::email($this->convertEmail($email));
198
-	}
190
+    /**
191
+     * Checks if an e-mail address is valid
192
+     *
193
+     * @param string $email Email address to be validated
194
+     * @return bool True if the mail address is valid, false otherwise
195
+     */
196
+    public function validateMailAddress(string $email): bool {
197
+        return \Swift_Validate::email($this->convertEmail($email));
198
+    }
199 199
 
200
-	/**
201
-	 * SwiftMailer does currently not work with IDN domains, this function therefore converts the domains
202
-	 *
203
-	 * FIXME: Remove this once SwiftMailer supports IDN
204
-	 *
205
-	 * @param string $email
206
-	 * @return string Converted mail address if `idn_to_ascii` exists
207
-	 */
208
-	protected function convertEmail(string $email): string {
209
-		if (!function_exists('idn_to_ascii') || !defined('INTL_IDNA_VARIANT_UTS46') || strpos($email, '@') === false) {
210
-			return $email;
211
-		}
200
+    /**
201
+     * SwiftMailer does currently not work with IDN domains, this function therefore converts the domains
202
+     *
203
+     * FIXME: Remove this once SwiftMailer supports IDN
204
+     *
205
+     * @param string $email
206
+     * @return string Converted mail address if `idn_to_ascii` exists
207
+     */
208
+    protected function convertEmail(string $email): string {
209
+        if (!function_exists('idn_to_ascii') || !defined('INTL_IDNA_VARIANT_UTS46') || strpos($email, '@') === false) {
210
+            return $email;
211
+        }
212 212
 
213
-		list($name, $domain) = explode('@', $email, 2);
214
-		$domain = idn_to_ascii($domain, 0,INTL_IDNA_VARIANT_UTS46);
215
-		return $name.'@'.$domain;
216
-	}
213
+        list($name, $domain) = explode('@', $email, 2);
214
+        $domain = idn_to_ascii($domain, 0,INTL_IDNA_VARIANT_UTS46);
215
+        return $name.'@'.$domain;
216
+    }
217 217
 
218
-	/**
219
-	 * Returns whatever transport is configured within the config
220
-	 *
221
-	 * @return \Swift_SmtpTransport|\Swift_SendmailTransport|\Swift_MailTransport
222
-	 */
223
-	protected function getInstance() {
224
-		if (!is_null($this->instance)) {
225
-			return $this->instance;
226
-		}
218
+    /**
219
+     * Returns whatever transport is configured within the config
220
+     *
221
+     * @return \Swift_SmtpTransport|\Swift_SendmailTransport|\Swift_MailTransport
222
+     */
223
+    protected function getInstance() {
224
+        if (!is_null($this->instance)) {
225
+            return $this->instance;
226
+        }
227 227
 
228
-		switch ($this->config->getSystemValue('mail_smtpmode', 'php')) {
229
-			case 'smtp':
230
-				$this->instance = $this->getSmtpInstance();
231
-				break;
232
-			case 'sendmail':
233
-				// FIXME: Move into the return statement but requires proper testing
234
-				//       for SMTP and mail as well. Thus not really doable for a
235
-				//       minor release.
236
-				$this->instance = \Swift_Mailer::newInstance($this->getSendMailInstance());
237
-				break;
238
-			default:
239
-				$this->instance = $this->getMailInstance();
240
-				break;
241
-		}
228
+        switch ($this->config->getSystemValue('mail_smtpmode', 'php')) {
229
+            case 'smtp':
230
+                $this->instance = $this->getSmtpInstance();
231
+                break;
232
+            case 'sendmail':
233
+                // FIXME: Move into the return statement but requires proper testing
234
+                //       for SMTP and mail as well. Thus not really doable for a
235
+                //       minor release.
236
+                $this->instance = \Swift_Mailer::newInstance($this->getSendMailInstance());
237
+                break;
238
+            default:
239
+                $this->instance = $this->getMailInstance();
240
+                break;
241
+        }
242 242
 
243
-		return $this->instance;
244
-	}
243
+        return $this->instance;
244
+    }
245 245
 
246
-	/**
247
-	 * Returns the SMTP transport
248
-	 *
249
-	 * @return \Swift_SmtpTransport
250
-	 */
251
-	protected function getSmtpInstance(): \Swift_SmtpTransport {
252
-		$transport = \Swift_SmtpTransport::newInstance();
253
-		$transport->setTimeout($this->config->getSystemValue('mail_smtptimeout', 10));
254
-		$transport->setHost($this->config->getSystemValue('mail_smtphost', '127.0.0.1'));
255
-		$transport->setPort($this->config->getSystemValue('mail_smtpport', 25));
256
-		if ($this->config->getSystemValue('mail_smtpauth', false)) {
257
-			$transport->setUsername($this->config->getSystemValue('mail_smtpname', ''));
258
-			$transport->setPassword($this->config->getSystemValue('mail_smtppassword', ''));
259
-			$transport->setAuthMode($this->config->getSystemValue('mail_smtpauthtype', 'LOGIN'));
260
-		}
261
-		$smtpSecurity = $this->config->getSystemValue('mail_smtpsecure', '');
262
-		if (!empty($smtpSecurity)) {
263
-			$transport->setEncryption($smtpSecurity);
264
-		}
265
-		$transport->start();
266
-		return $transport;
267
-	}
246
+    /**
247
+     * Returns the SMTP transport
248
+     *
249
+     * @return \Swift_SmtpTransport
250
+     */
251
+    protected function getSmtpInstance(): \Swift_SmtpTransport {
252
+        $transport = \Swift_SmtpTransport::newInstance();
253
+        $transport->setTimeout($this->config->getSystemValue('mail_smtptimeout', 10));
254
+        $transport->setHost($this->config->getSystemValue('mail_smtphost', '127.0.0.1'));
255
+        $transport->setPort($this->config->getSystemValue('mail_smtpport', 25));
256
+        if ($this->config->getSystemValue('mail_smtpauth', false)) {
257
+            $transport->setUsername($this->config->getSystemValue('mail_smtpname', ''));
258
+            $transport->setPassword($this->config->getSystemValue('mail_smtppassword', ''));
259
+            $transport->setAuthMode($this->config->getSystemValue('mail_smtpauthtype', 'LOGIN'));
260
+        }
261
+        $smtpSecurity = $this->config->getSystemValue('mail_smtpsecure', '');
262
+        if (!empty($smtpSecurity)) {
263
+            $transport->setEncryption($smtpSecurity);
264
+        }
265
+        $transport->start();
266
+        return $transport;
267
+    }
268 268
 
269
-	/**
270
-	 * Returns the sendmail transport
271
-	 *
272
-	 * @return \Swift_SendmailTransport
273
-	 */
274
-	protected function getSendMailInstance(): \Swift_SendmailTransport {
275
-		switch ($this->config->getSystemValue('mail_smtpmode', 'php')) {
276
-			case 'qmail':
277
-				$binaryPath = '/var/qmail/bin/sendmail';
278
-				break;
279
-			default:
280
-				$binaryPath = '/usr/sbin/sendmail';
281
-				break;
282
-		}
269
+    /**
270
+     * Returns the sendmail transport
271
+     *
272
+     * @return \Swift_SendmailTransport
273
+     */
274
+    protected function getSendMailInstance(): \Swift_SendmailTransport {
275
+        switch ($this->config->getSystemValue('mail_smtpmode', 'php')) {
276
+            case 'qmail':
277
+                $binaryPath = '/var/qmail/bin/sendmail';
278
+                break;
279
+            default:
280
+                $binaryPath = '/usr/sbin/sendmail';
281
+                break;
282
+        }
283 283
 
284
-		return \Swift_SendmailTransport::newInstance($binaryPath . ' -bs');
285
-	}
284
+        return \Swift_SendmailTransport::newInstance($binaryPath . ' -bs');
285
+    }
286 286
 
287
-	/**
288
-	 * Returns the mail transport
289
-	 *
290
-	 * @return \Swift_MailTransport
291
-	 */
292
-	protected function getMailInstance(): \Swift_MailTransport {
293
-		return \Swift_MailTransport::newInstance();
294
-	}
287
+    /**
288
+     * Returns the mail transport
289
+     *
290
+     * @return \Swift_MailTransport
291
+     */
292
+    protected function getMailInstance(): \Swift_MailTransport {
293
+        return \Swift_MailTransport::newInstance();
294
+    }
295 295
 
296 296
 }
Please login to merge, or discard this patch.