@@ -273,19 +273,22 @@ private function setEmailTo(array &$target, string $targetAlias, string $address
273273 * @param string $targetAlias Alias Target alias.
274274 * @param string $address User e-mail address.
275275 * @param string|null $name Username (optional).
276- * @throws Exception
277276 * @return bool True if successful, false otherwise.
278277 */
279278 private function addEmailTo (array &$ target , string $ targetAlias , string $ address , ?string $ name = null ): bool
280279 {
281280 // Check
282281 if (!self ::validateEmail ($ address )) {
283- throw new Exception ('" ' . $ address . '" is not a valid email address! ' );
282+ $ this ->configuration ->getLogger ()->error ('" ' . $ address . '" is not a valid email address! ' );
283+ return false ;
284284 }
285285
286286 // Don't allow duplicated addresses
287287 if (array_key_exists ($ address , $ target )) {
288- throw new Exception ('" ' . $ address . '" has been already added in ' . $ targetAlias . '! ' );
288+ $ this ->configuration ->getLogger ()->error (
289+ '" ' . $ address . '" has been already added in ' . $ targetAlias . '! '
290+ );
291+ return false ;
289292 }
290293
291294 if (isset ($ name )) {
@@ -302,14 +305,15 @@ private function addEmailTo(array &$target, string $targetAlias, string $address
302305
303306 // Add the email address into the target array
304307 $ target [$ address ] = $ name ;
305- // On Windows, when using PHP built-in mail drop any name, just use the e-mail address
308+ // On Windows, when using PHP built-in mail drops any name, just use the e-mail address
306309 if ('WIN ' !== strtoupper (substr (PHP_OS , 0 , 3 ))) {
307310 return true ;
308311 }
309312 if ('built-in ' != $ this ->agent ) {
310313 return true ;
311314 }
312315 $ target [$ address ] = null ;
316+
313317 return true ;
314318 }
315319
@@ -330,6 +334,7 @@ public static function validateEmail(string $address): bool
330334 if ($ address !== str_replace ($ unsafe , '' , $ address )) {
331335 return false ;
332336 }
337+
333338 return (bool ) filter_var ($ address , FILTER_VALIDATE_EMAIL );
334339 }
335340
0 commit comments