Merge pull request #1087 from wilr/5

FIX Log any email exceptions gracefully
This commit is contained in:
Daniel Hensby 2021-06-22 11:16:18 +01:00 committed by GitHub
commit 15e834de87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 2 deletions

View File

@ -2,6 +2,7 @@
namespace SilverStripe\UserForms\Control;
use Exception;
use PageController;
use Psr\Log\LoggerInterface;
use SilverStripe\AssetAdmin\Controller\AssetAdmin;
@ -429,9 +430,18 @@ JS
}
$email->setBody($body);
$email->sendPlain();
try {
$email->sendPlain();
} catch (Exception $e) {
Injector::inst()->get(LoggerInterface::class)->error($e);
}
} else {
$email->send();
try {
$email->send();
} catch (Exception $e) {
Injector::inst()->get(LoggerInterface::class)->error($e);
}
}
}
}