Completed
Pull Request — master (#4372)
by Joas
60:09 queued 22:14
created
settings/templates/admin/additional-mail.php 3 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -25,27 +25,27 @@  discard block
 block discarded – undo
25 25
 /** @var array $_ */
26 26
 
27 27
 $mail_smtpauthtype = [
28
-	''	=> $l->t('None'),
29
-	'LOGIN'	=> $l->t('Login'),
30
-	'PLAIN'	=> $l->t('Plain'),
31
-	'NTLM'	=> $l->t('NT LAN Manager'),
28
+    ''	=> $l->t('None'),
29
+    'LOGIN'	=> $l->t('Login'),
30
+    'PLAIN'	=> $l->t('Plain'),
31
+    'NTLM'	=> $l->t('NT LAN Manager'),
32 32
 ];
33 33
 
34 34
 $mail_smtpsecure = [
35
-	''		=> $l->t('None'),
36
-	'ssl'	=> $l->t('SSL/TLS'),
37
-	'tls'	=> $l->t('STARTTLS'),
35
+    ''		=> $l->t('None'),
36
+    'ssl'	=> $l->t('SSL/TLS'),
37
+    'tls'	=> $l->t('STARTTLS'),
38 38
 ];
39 39
 
40 40
 $mail_smtpmode = [
41
-	['php', 'PHP'],
42
-	['smtp', 'SMTP'],
41
+    ['php', 'PHP'],
42
+    ['smtp', 'SMTP'],
43 43
 ];
44 44
 if ($_['sendmail_is_available']) {
45
-	$mail_smtpmode[] = ['sendmail', 'Sendmail'];
45
+    $mail_smtpmode[] = ['sendmail', 'Sendmail'];
46 46
 }
47 47
 if ($_['mail_smtpmode'] === 'qmail') {
48
-	$mail_smtpmode[] = ['qmail', 'qmail'];
48
+    $mail_smtpmode[] = ['qmail', 'qmail'];
49 49
 }
50 50
 
51 51
 ?>
@@ -63,10 +63,10 @@  discard block
 block discarded – undo
63 63
 			<label for="mail_smtpmode"><?php p($l->t('Send mode')); ?></label>
64 64
 			<select name="mail_smtpmode" id="mail_smtpmode'>
65 65
 				<?php foreach ($mail_smtpmode as $smtpmode):
66
-					$selected = '';
67
-					if ($smtpmode[0] == $_['mail_smtpmode']):
68
-						$selected = 'selected="selected"';
69
-					endif; ?>
66
+                    $selected = '';
67
+                    if ($smtpmode[0] == $_['mail_smtpmode']):
68
+                        $selected = 'selected="selected"';
69
+                    endif; ?>
70 70
 					<option value="<?php p($smtpmode[0])?>" <?php p($selected) ?>><?php p($smtpmode[1]) ?></option>
71 71
 				<?php endforeach;?>
72 72
 			</select>
@@ -78,10 +78,10 @@  discard block
 block discarded – undo
78 78
 			<select name="mail_smtpsecure" id="mail_smtpsecure"
79 79
 				<?php if ($_['mail_smtpmode'] !== 'smtp') print_unescaped(' class="hidden"'); ?>>
80 80
 				<?php foreach ($mail_smtpsecure as $secure => $name):
81
-					$selected = '';
82
-					if ($secure == $_['mail_smtpsecure']):
83
-						$selected = 'selected="selected"';
84
-					endif; ?>
81
+                    $selected = '';
82
+                    if ($secure == $_['mail_smtpsecure']):
83
+                        $selected = 'selected="selected"';
84
+                    endif; ?>
85 85
 					<option value="<?php p($secure)?>" <?php p($selected) ?>><?php p($name) ?></option>
86 86
 				<?php endforeach;?>
87 87
 			</select>
@@ -99,10 +99,10 @@  discard block
 block discarded – undo
99 99
 			<label for="mail_smtpauthtype"><?php p($l->t('Authentication method')); ?></label>
100 100
 			<select name="mail_smtpauthtype" id="mail_smtpauthtype'>
101 101
 				<?php foreach ($mail_smtpauthtype as $authtype => $name):
102
-					$selected = '';
103
-					if ($authtype == $_['mail_smtpauthtype']):
104
-						$selected = 'selected="selected"';
105
-					endif; ?>
102
+                    $selected = '';
103
+                    if ($authtype == $_['mail_smtpauthtype']):
104
+                        $selected = 'selected="selected"';
105
+                    endif; ?>
106 106
 					<option value="<?php p($authtype)?>" <?php p($selected) ?>><?php p($name) ?></option>
107 107
 				<?php endforeach;?>
108 108
 			</select>
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 
53 53
 <div class="section" id="mail_general_settings">
54 54
 	<form id="mail_general_settings_form" class="mail_settings">
55
-		<h2><?php p($l->t('Email server'));?></h2>
55
+		<h2><?php p($l->t('Email server')); ?></h2>
56 56
 		<a target="_blank" rel="noreferrer" class="icon-info"
57
-		   title="<?php p($l->t('Open documentation'));?>"
57
+		   title="<?php p($l->t('Open documentation')); ?>"
58 58
 		   href="<?php p(link_to_docs('admin-email')); ?>"></a>
59 59
 
60 60
 		<p><?php p($l->t('This is used for sending out notifications.')); ?> <span id="mail_settings_msg" class="msg"></span></p>
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 						$selected = 'selected="selected"';
69 69
 					endif; ?>
70 70
 					<option value="<?php p($smtpmode[0])?>" <?php p($selected) ?>><?php p($smtpmode[1]) ?></option>
71
-				<?php endforeach;?>
71
+				<?php endforeach; ?>
72 72
 			</select>
73 73
 
74 74
 			<label id="mail_smtpsecure_label" for="mail_smtpsecure"
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 						$selected = 'selected="selected"';
84 84
 					endif; ?>
85 85
 					<option value="<?php p($secure)?>" <?php p($selected) ?>><?php p($name) ?></option>
86
-				<?php endforeach;?>
86
+				<?php endforeach; ?>
87 87
 			</select>
88 88
 		</p>
89 89
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 						$selected = 'selected="selected"';
105 105
 					endif; ?>
106 106
 					<option value="<?php p($authtype)?>" <?php p($selected) ?>><?php p($name) ?></option>
107
-				<?php endforeach;?>
107
+				<?php endforeach; ?>
108 108
 			</select>
109 109
 
110 110
 			<input type="checkbox" name="mail_smtpauth" id="mail_smtpauth" class="checkbox" value="1"
Please login to merge, or discard this patch.
Braces   +24 added lines, -6 removed lines patch added patch discarded remove patch
@@ -72,11 +72,17 @@  discard block
 block discarded – undo
72 72
 			</select>
73 73
 
74 74
 			<label id="mail_smtpsecure_label" for="mail_smtpsecure"
75
-				<?php if ($_['mail_smtpmode'] !== 'smtp') print_unescaped(' class="hidden"'); ?>>
75
+				<?php if ($_['mail_smtpmode'] !== 'smtp') {
76
+    print_unescaped(' class="hidden"');
77
+}
78
+?>>
76 79
 				<?php p($l->t('Encryption')); ?>
77 80
 			</label>
78 81
 			<select name="mail_smtpsecure" id="mail_smtpsecure"
79
-				<?php if ($_['mail_smtpmode'] !== 'smtp') print_unescaped(' class="hidden"'); ?>>
82
+				<?php if ($_['mail_smtpmode'] !== 'smtp') {
83
+    print_unescaped(' class="hidden"');
84
+}
85
+?>>
80 86
 				<?php foreach ($mail_smtpsecure as $secure => $name):
81 87
 					$selected = '';
82 88
 					if ($secure == $_['mail_smtpsecure']):
@@ -95,7 +101,10 @@  discard block
 block discarded – undo
95 101
 				   value="<?php p($_['mail_domain']) ?>" />
96 102
 		</p>
97 103
 
98
-		<p id="setting_smtpauth" <?php if ($_['mail_smtpmode'] !== 'smtp') print_unescaped(' class="hidden"'); ?>>
104
+		<p id="setting_smtpauth" <?php if ($_['mail_smtpmode'] !== 'smtp') {
105
+    print_unescaped(' class="hidden"');
106
+}
107
+?>>
99 108
 			<label for="mail_smtpauthtype"><?php p($l->t('Authentication method')); ?></label>
100 109
 			<select name="mail_smtpauthtype" id="mail_smtpauthtype'>
101 110
 				<?php foreach ($mail_smtpauthtype as $authtype => $name):
@@ -108,11 +117,17 @@  discard block
 block discarded – undo
108 117
 			</select>
109 118
 
110 119
 			<input type="checkbox" name="mail_smtpauth" id="mail_smtpauth" class="checkbox" value="1"
111
-				<?php if ($_['mail_smtpauth']) print_unescaped('checked="checked"'); ?> />
120
+				<?php if ($_['mail_smtpauth']) {
121
+    print_unescaped('checked="checked"');
122
+}
123
+?> />
112 124
 			<label for="mail_smtpauth"><?php p($l->t('Authentication required')); ?></label>
113 125
 		</p>
114 126
 
115
-		<p id="setting_smtphost" <?php if ($_['mail_smtpmode'] !== 'smtp') print_unescaped(' class="hidden"'); ?>>
127
+		<p id="setting_smtphost" <?php if ($_['mail_smtpmode'] !== 'smtp') {
128
+    print_unescaped(' class="hidden"');
129
+}
130
+?>>
116 131
 			<label for="mail_smtphost"><?php p($l->t('Server address')); ?></label>
117 132
 			<input type="text" name="mail_smtphost" id="mail_smtphost" placeholder="smtp.example.com"
118 133
 				   value="<?php p($_['mail_smtphost']) ?>" />
@@ -122,7 +137,10 @@  discard block
 block discarded – undo
122 137
 		</p>
123 138
 	</form>
124 139
 	<form class="mail_settings" id="mail_credentials_settings">
125
-		<p id="mail_credentials" <?php if (!$_['mail_smtpauth'] || $_['mail_smtpmode'] !== 'smtp') print_unescaped(' class="hidden"'); ?>>
140
+		<p id="mail_credentials" <?php if (!$_['mail_smtpauth'] || $_['mail_smtpmode'] !== 'smtp') {
141
+    print_unescaped(' class="hidden"');
142
+}
143
+?>>
126 144
 			<label for="mail_smtpname"><?php p($l->t('Credentials')); ?></label>
127 145
 			<input type="text" name="mail_smtpname" id="mail_smtpname" placeholder="<?php p($l->t('SMTP Username'))?>"
128 146
 				   value="<?php p($_['mail_smtpname']) ?>" />
Please login to merge, or discard this patch.
lib/private/Settings/Admin/Additional.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -36,57 +36,57 @@
 block discarded – undo
36 36
 use OCP\Settings\ISettings;
37 37
 
38 38
 class Additional implements ISettings {
39
-	/** @var IConfig */
40
-	private $config;
39
+    /** @var IConfig */
40
+    private $config;
41 41
 
42
-	/**
43
-	 * @param IConfig $config
44
-	 */
45
-	public function __construct(IConfig $config) {
46
-		$this->config = $config;
47
-	}
42
+    /**
43
+     * @param IConfig $config
44
+     */
45
+    public function __construct(IConfig $config) {
46
+        $this->config = $config;
47
+    }
48 48
 
49
-	/**
50
-	 * @return TemplateResponse
51
-	 */
52
-	public function getForm() {
53
-		$parameters = [
54
-			// Mail
55
-			'sendmail_is_available' => (bool) \OC_Helper::findBinaryPath('sendmail'),
56
-			'mail_domain'           => $this->config->getSystemValue('mail_domain', ''),
57
-			'mail_from_address'     => $this->config->getSystemValue('mail_from_address', ''),
58
-			'mail_smtpmode'         => $this->config->getSystemValue('mail_smtpmode', ''),
59
-			'mail_smtpsecure'       => $this->config->getSystemValue('mail_smtpsecure', ''),
60
-			'mail_smtphost'         => $this->config->getSystemValue('mail_smtphost', ''),
61
-			'mail_smtpport'         => $this->config->getSystemValue('mail_smtpport', ''),
62
-			'mail_smtpauthtype'     => $this->config->getSystemValue('mail_smtpauthtype', ''),
63
-			'mail_smtpauth'         => $this->config->getSystemValue('mail_smtpauth', false),
64
-			'mail_smtpname'         => $this->config->getSystemValue('mail_smtpname', ''),
65
-			'mail_smtppassword'     => $this->config->getSystemValue('mail_smtppassword', ''),
66
-		];
49
+    /**
50
+     * @return TemplateResponse
51
+     */
52
+    public function getForm() {
53
+        $parameters = [
54
+            // Mail
55
+            'sendmail_is_available' => (bool) \OC_Helper::findBinaryPath('sendmail'),
56
+            'mail_domain'           => $this->config->getSystemValue('mail_domain', ''),
57
+            'mail_from_address'     => $this->config->getSystemValue('mail_from_address', ''),
58
+            'mail_smtpmode'         => $this->config->getSystemValue('mail_smtpmode', ''),
59
+            'mail_smtpsecure'       => $this->config->getSystemValue('mail_smtpsecure', ''),
60
+            'mail_smtphost'         => $this->config->getSystemValue('mail_smtphost', ''),
61
+            'mail_smtpport'         => $this->config->getSystemValue('mail_smtpport', ''),
62
+            'mail_smtpauthtype'     => $this->config->getSystemValue('mail_smtpauthtype', ''),
63
+            'mail_smtpauth'         => $this->config->getSystemValue('mail_smtpauth', false),
64
+            'mail_smtpname'         => $this->config->getSystemValue('mail_smtpname', ''),
65
+            'mail_smtppassword'     => $this->config->getSystemValue('mail_smtppassword', ''),
66
+        ];
67 67
 
68
-		if ($parameters['mail_smtppassword'] !== '') {
69
-			$parameters['mail_smtppassword'] = '********';
70
-		}
68
+        if ($parameters['mail_smtppassword'] !== '') {
69
+            $parameters['mail_smtppassword'] = '********';
70
+        }
71 71
 
72
-		return new TemplateResponse('settings', 'admin/additional-mail', $parameters, '');
73
-	}
72
+        return new TemplateResponse('settings', 'admin/additional-mail', $parameters, '');
73
+    }
74 74
 
75
-	/**
76
-	 * @return string the section ID, e.g. 'sharing'
77
-	 */
78
-	public function getSection() {
79
-		return 'additional';
80
-	}
75
+    /**
76
+     * @return string the section ID, e.g. 'sharing'
77
+     */
78
+    public function getSection() {
79
+        return 'additional';
80
+    }
81 81
 
82
-	/**
83
-	 * @return int whether the form should be rather on the top or bottom of
84
-	 * the admin section. The forms are arranged in ascending order of the
85
-	 * priority values. It is required to return a value between 0 and 100.
86
-	 *
87
-	 * E.g.: 70
88
-	 */
89
-	public function getPriority() {
90
-		return 0;
91
-	}
82
+    /**
83
+     * @return int whether the form should be rather on the top or bottom of
84
+     * the admin section. The forms are arranged in ascending order of the
85
+     * priority values. It is required to return a value between 0 and 100.
86
+     *
87
+     * E.g.: 70
88
+     */
89
+    public function getPriority() {
90
+        return 0;
91
+    }
92 92
 }
Please login to merge, or discard this patch.
settings/Controller/MailSettingsController.php 1 patch
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -38,128 +38,128 @@
 block discarded – undo
38 38
  */
39 39
 class MailSettingsController extends Controller {
40 40
 
41
-	/** @var IL10N */
42
-	private $l10n;
43
-	/** @var IConfig */
44
-	private $config;
45
-	/** @var IUserSession */
46
-	private $userSession;
47
-	/** @var IMailer */
48
-	private $mailer;
49
-	/** @var string */
50
-	private $defaultMailAddress;
51
-
52
-	/**
53
-	 * @param string $appName
54
-	 * @param IRequest $request
55
-	 * @param IL10N $l10n
56
-	 * @param IConfig $config
57
-	 * @param IUserSession $userSession
58
-	 * @param IMailer $mailer
59
-	 * @param string $fromMailAddress
60
-	 */
61
-	public function __construct($appName,
62
-								IRequest $request,
63
-								IL10N $l10n,
64
-								IConfig $config,
65
-								IUserSession $userSession,
66
-								IMailer $mailer,
67
-								$fromMailAddress) {
68
-		parent::__construct($appName, $request);
69
-		$this->l10n = $l10n;
70
-		$this->config = $config;
71
-		$this->userSession = $userSession;
72
-		$this->mailer = $mailer;
73
-		$this->defaultMailAddress = $fromMailAddress;
74
-	}
75
-
76
-	/**
77
-	 * Sets the email settings
78
-	 *
79
-	 * @PasswordConfirmationRequired
80
-	 *
81
-	 * @param string $mail_domain
82
-	 * @param string $mail_from_address
83
-	 * @param string $mail_smtpmode
84
-	 * @param string $mail_smtpsecure
85
-	 * @param string $mail_smtphost
86
-	 * @param string $mail_smtpauthtype
87
-	 * @param int $mail_smtpauth
88
-	 * @param string $mail_smtpport
89
-	 * @return DataResponse
90
-	 */
91
-	public function setMailSettings($mail_domain,
92
-									$mail_from_address,
93
-									$mail_smtpmode,
94
-									$mail_smtpsecure,
95
-									$mail_smtphost,
96
-									$mail_smtpauthtype,
97
-									$mail_smtpauth,
98
-									$mail_smtpport) {
99
-
100
-		$params = get_defined_vars();
101
-		$configs = [];
102
-		foreach($params as $key => $value) {
103
-			$configs[$key] = (empty($value)) ? null : $value;
104
-		}
105
-
106
-		// Delete passwords from config in case no auth is specified
107
-		if ($params['mail_smtpauth'] !== 1) {
108
-			$configs['mail_smtpname'] = null;
109
-			$configs['mail_smtppassword'] = null;
110
-		}
111
-
112
-		$this->config->setSystemValues($configs);
113
-
114
-		return new DataResponse();
115
-	}
116
-
117
-	/**
118
-	 * Store the credentials used for SMTP in the config
119
-	 *
120
-	 * @PasswordConfirmationRequired
121
-	 *
122
-	 * @param string $mail_smtpname
123
-	 * @param string $mail_smtppassword
124
-	 * @return DataResponse
125
-	 */
126
-	public function storeCredentials($mail_smtpname, $mail_smtppassword) {
127
-		if ($mail_smtppassword === '********') {
128
-			return new DataResponse($this->l10n->t('Invalid SMTP password.'), Http::STATUS_BAD_REQUEST);
129
-		}
130
-
131
-		$this->config->setSystemValues([
132
-			'mail_smtpname'		=> $mail_smtpname,
133
-			'mail_smtppassword'	=> $mail_smtppassword,
134
-		]);
135
-
136
-		return new DataResponse();
137
-	}
138
-
139
-	/**
140
-	 * Send a mail to test the settings
141
-	 * @return DataResponse
142
-	 */
143
-	public function sendTestMail() {
144
-		$email = $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'email', '');
145
-		if (!empty($email)) {
146
-			try {
147
-				$message = $this->mailer->createMessage();
148
-				$message->setTo([$email => $this->userSession->getUser()->getDisplayName()]);
149
-				$message->setFrom([$this->defaultMailAddress]);
150
-				$message->setSubject($this->l10n->t('test email settings'));
151
-				$message->setPlainBody('If you received this email, the settings seem to be correct.');
152
-				$errors = $this->mailer->send($message);
153
-				if (!empty($errors)) {
154
-					throw new \RuntimeException($this->l10n->t('Mail could not be sent. Check your mail server log'));
155
-				}
156
-				return new DataResponse();
157
-			} catch (\Exception $e) {
158
-				return new DataResponse($this->l10n->t('A problem occurred while sending the email. Please revise your settings. (Error: %s)', [$e->getMessage()]), Http::STATUS_BAD_REQUEST);
159
-			}
160
-		}
161
-
162
-		return new DataResponse($this->l10n->t('You need to set your user email before being able to send test emails.'), Http::STATUS_BAD_REQUEST);
163
-	}
41
+    /** @var IL10N */
42
+    private $l10n;
43
+    /** @var IConfig */
44
+    private $config;
45
+    /** @var IUserSession */
46
+    private $userSession;
47
+    /** @var IMailer */
48
+    private $mailer;
49
+    /** @var string */
50
+    private $defaultMailAddress;
51
+
52
+    /**
53
+     * @param string $appName
54
+     * @param IRequest $request
55
+     * @param IL10N $l10n
56
+     * @param IConfig $config
57
+     * @param IUserSession $userSession
58
+     * @param IMailer $mailer
59
+     * @param string $fromMailAddress
60
+     */
61
+    public function __construct($appName,
62
+                                IRequest $request,
63
+                                IL10N $l10n,
64
+                                IConfig $config,
65
+                                IUserSession $userSession,
66
+                                IMailer $mailer,
67
+                                $fromMailAddress) {
68
+        parent::__construct($appName, $request);
69
+        $this->l10n = $l10n;
70
+        $this->config = $config;
71
+        $this->userSession = $userSession;
72
+        $this->mailer = $mailer;
73
+        $this->defaultMailAddress = $fromMailAddress;
74
+    }
75
+
76
+    /**
77
+     * Sets the email settings
78
+     *
79
+     * @PasswordConfirmationRequired
80
+     *
81
+     * @param string $mail_domain
82
+     * @param string $mail_from_address
83
+     * @param string $mail_smtpmode
84
+     * @param string $mail_smtpsecure
85
+     * @param string $mail_smtphost
86
+     * @param string $mail_smtpauthtype
87
+     * @param int $mail_smtpauth
88
+     * @param string $mail_smtpport
89
+     * @return DataResponse
90
+     */
91
+    public function setMailSettings($mail_domain,
92
+                                    $mail_from_address,
93
+                                    $mail_smtpmode,
94
+                                    $mail_smtpsecure,
95
+                                    $mail_smtphost,
96
+                                    $mail_smtpauthtype,
97
+                                    $mail_smtpauth,
98
+                                    $mail_smtpport) {
99
+
100
+        $params = get_defined_vars();
101
+        $configs = [];
102
+        foreach($params as $key => $value) {
103
+            $configs[$key] = (empty($value)) ? null : $value;
104
+        }
105
+
106
+        // Delete passwords from config in case no auth is specified
107
+        if ($params['mail_smtpauth'] !== 1) {
108
+            $configs['mail_smtpname'] = null;
109
+            $configs['mail_smtppassword'] = null;
110
+        }
111
+
112
+        $this->config->setSystemValues($configs);
113
+
114
+        return new DataResponse();
115
+    }
116
+
117
+    /**
118
+     * Store the credentials used for SMTP in the config
119
+     *
120
+     * @PasswordConfirmationRequired
121
+     *
122
+     * @param string $mail_smtpname
123
+     * @param string $mail_smtppassword
124
+     * @return DataResponse
125
+     */
126
+    public function storeCredentials($mail_smtpname, $mail_smtppassword) {
127
+        if ($mail_smtppassword === '********') {
128
+            return new DataResponse($this->l10n->t('Invalid SMTP password.'), Http::STATUS_BAD_REQUEST);
129
+        }
130
+
131
+        $this->config->setSystemValues([
132
+            'mail_smtpname'		=> $mail_smtpname,
133
+            'mail_smtppassword'	=> $mail_smtppassword,
134
+        ]);
135
+
136
+        return new DataResponse();
137
+    }
138
+
139
+    /**
140
+     * Send a mail to test the settings
141
+     * @return DataResponse
142
+     */
143
+    public function sendTestMail() {
144
+        $email = $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'email', '');
145
+        if (!empty($email)) {
146
+            try {
147
+                $message = $this->mailer->createMessage();
148
+                $message->setTo([$email => $this->userSession->getUser()->getDisplayName()]);
149
+                $message->setFrom([$this->defaultMailAddress]);
150
+                $message->setSubject($this->l10n->t('test email settings'));
151
+                $message->setPlainBody('If you received this email, the settings seem to be correct.');
152
+                $errors = $this->mailer->send($message);
153
+                if (!empty($errors)) {
154
+                    throw new \RuntimeException($this->l10n->t('Mail could not be sent. Check your mail server log'));
155
+                }
156
+                return new DataResponse();
157
+            } catch (\Exception $e) {
158
+                return new DataResponse($this->l10n->t('A problem occurred while sending the email. Please revise your settings. (Error: %s)', [$e->getMessage()]), Http::STATUS_BAD_REQUEST);
159
+            }
160
+        }
161
+
162
+        return new DataResponse($this->l10n->t('You need to set your user email before being able to send test emails.'), Http::STATUS_BAD_REQUEST);
163
+    }
164 164
 
165 165
 }
Please login to merge, or discard this patch.