diff --git a/libraries/joomla/factory.php b/libraries/joomla/factory.php index 0447213276015..d086a19057072 100644 --- a/libraries/joomla/factory.php +++ b/libraries/joomla/factory.php @@ -671,8 +671,26 @@ protected static function createMailer() // Create a JMail object $mail = JMail::getInstance(); - // Set default sender without Reply-to - $mail->SetFrom(JMailHelper::cleanLine($mailfrom), JMailHelper::cleanLine($fromname), 0); + // Clean the email address + $mailfrom = JMailHelper::cleanLine($mailfrom); + + // Set default sender without Reply-to if the mailfrom is a valid address + if (JMailHelper::isEmailAddress($mailfrom)) + { + // Wrap in try/catch to catch phpmailerExceptions if it is throwing them + try + { + // Check for a false return value if exception throwing is disabled + if ($mail->setFrom($mailfrom, JMailHelper::cleanLine($fromname), false) === false) + { + JLog::add(__METHOD__ . '() could not set the sender data.', JLog::WARNING, 'mail'); + } + } + catch (phpmailerException $e) + { + JLog::add(__METHOD__ . '() could not set the sender data.', JLog::WARNING, 'mail'); + } + } // Default mailer is to use PHP's mail function switch ($mailer) @@ -682,11 +700,11 @@ protected static function createMailer() break; case 'sendmail': - $mail->IsSendmail(); + $mail->isSendmail(); break; default: - $mail->IsMail(); + $mail->isMail(); break; }