return \OC_Helper::isReadOnlyConfigEnabled();
}
+ protected function wasEmailTestSuccessful(): bool {
+ // Handle the case that the configuration was set before the check was introduced or it was only set via command line and not from the UI
+ if ($this->config->getAppValue('core', 'emailTestSuccessful', '') === '' && $this->config->getSystemValue('mail_domain', '') === '') {
+ return false;
+ }
+
+ // The mail test was unsuccessful or the config was changed using the UI without verifying with a testmail, hence return false
+ if ($this->config->getAppValue('core', 'emailTestSuccessful', '') === '0') {
+ return false;
+ }
+
+ return true;
+ }
+
protected function hasValidTransactionIsolationLevel(): bool {
try {
if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) {
'isGetenvServerWorking' => !empty(getenv('PATH')),
'isReadOnlyConfig' => $this->isReadOnlyConfig(),
'hasValidTransactionIsolationLevel' => $this->hasValidTransactionIsolationLevel(),
+ 'wasEmailTestSuccessful' => $this->wasEmailTestSuccessful(),
'hasFileinfoInstalled' => $this->hasFileinfoInstalled(),
'hasWorkingFileLocking' => $this->hasWorkingFileLocking(),
'suggestedOverwriteCliURL' => $this->getSuggestedOverwriteCliURL(),
use OCP\IConfig;
use OCP\IL10N;
use OCP\IRequest;
+use OCP\IURLGenerator;
use OCP\IUserSession;
use OCP\Mail\IMailer;
private $userSession;
/** @var IMailer */
private $mailer;
+ /** @var IURLGenerator */
+ private $urlGenerator;
/**
* @param string $appName
* @param IL10N $l10n
* @param IConfig $config
* @param IUserSession $userSession
+ * @param IURLGenerator $urlGenerator,
* @param IMailer $mailer
*/
public function __construct($appName,
IL10N $l10n,
IConfig $config,
IUserSession $userSession,
+ IURLGenerator $urlGenerator,
IMailer $mailer) {
parent::__construct($appName, $request);
$this->l10n = $l10n;
$this->config = $config;
$this->userSession = $userSession;
+ $this->urlGenerator = $urlGenerator;
$this->mailer = $mailer;
}
$this->config->setSystemValues($configs);
+ $this->config->setAppValue('core', 'emailTestSuccessful', '0');
+
return new DataResponse();
}
'mail_smtppassword' => $mail_smtppassword,
]);
+ $this->config->setAppValue('core', 'emailTestSuccessful', '0');
+
return new DataResponse();
}
$message->useTemplate($template);
$errors = $this->mailer->send($message);
if (!empty($errors)) {
+ $this->config->setAppValue('core', 'emailTestSuccessful', '0');
throw new \RuntimeException($this->l10n->t('Email could not be sent. Check your mail server log'));
}
+ // Store the successful config in the app config
+ $this->config->setAppValue('core', 'emailTestSuccessful', '1');
return new DataResponse();
} catch (\Exception $e) {
+ $this->config->setAppValue('core', 'emailTestSuccessful', '0');
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);
}
}
- return new DataResponse($this->l10n->t('You need to set your user email before being able to send test emails.'), Http::STATUS_BAD_REQUEST);
+ $this->config->setAppValue('core', 'emailTestSuccessful', '0');
+ return new DataResponse($this->l10n->t('You need to set your user email before being able to send test emails. Go to %s for that.', [$this->urlGenerator->linkToRouteAbsolute('settings.PersonalSettings.index')]), Http::STATUS_BAD_REQUEST);
}
}
type: OC.SetupChecks.MESSAGE_TYPE_INFO
});
}
+ if (!data.wasEmailTestSuccessful) {
+ messages.push({
+ msg: t('core', 'You have not set or verified your email server configuration, yet. Please head over to the {mailSettingsStart} Basic settings {mailSettingsEnd} in order to set them. Afterwards, use the "Send email" button below the form to verify your settings.',)
+ .replace('{mailSettingsStart} ', '<a href="' + OC.generateUrl('/settings/admin') + '">')
+ .replace(' {mailSettingsEnd}', '</a>'),
+ type: OC.SetupChecks.MESSAGE_TYPE_INFO
+ });
+ }
if (!data.hasValidTransactionIsolationLevel) {
messages.push({
msg: t('core', 'Your database does not run with "READ COMMITTED" transaction isolation level. This can cause problems when multiple actions are executed in parallel.'),