mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
FIX Log any email exceptions gracefully
If an email send() generates any errors such as invalid template or API exceptions then capture the error in the logs rather than displaying the error to the user.
This commit is contained in:
parent
e2f4378fff
commit
18eccb65d4
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace SilverStripe\UserForms\Control;
|
namespace SilverStripe\UserForms\Control;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
use PageController;
|
use PageController;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use SilverStripe\AssetAdmin\Controller\AssetAdmin;
|
use SilverStripe\AssetAdmin\Controller\AssetAdmin;
|
||||||
@ -429,9 +430,18 @@ JS
|
|||||||
}
|
}
|
||||||
|
|
||||||
$email->setBody($body);
|
$email->setBody($body);
|
||||||
|
|
||||||
|
try {
|
||||||
$email->sendPlain();
|
$email->sendPlain();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Injector::inst()->get(LoggerInterface::class)->error($e);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
try {
|
||||||
$email->send();
|
$email->send();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Injector::inst()->get(LoggerInterface::class)->error($e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user