diff --git a/application/config/mail.php b/application/config/mail.php index 07da6b430..7842ce8c0 100644 --- a/application/config/mail.php +++ b/application/config/mail.php @@ -1,30 +1,31 @@ ci->email->from($from, $alias); - $this->ci->email->to($to); + + // Check if the email address of the debug recipient is a valid one + $recipient = $to; + if ($this->validateEmailAddress(MAIL_DEBUG)) + { + // if is it valid use it!!! + $recipient = MAIL_DEBUG; + } + + $this->ci->email->to($recipient); if (!is_null($cc)) $this->ci->email->cc($cc); if (!is_null($bcc)) $this->ci->email->bcc($bcc); $this->ci->email->subject($subject); @@ -115,6 +124,21 @@ class MailLib return $cfg; } + /** + * Validates an email address + */ + public function validateEmailAddress($emailAddress) + { + $valid = false; + + if (!empty($emailAddress)) + { + $valid = filter_var($emailAddress, FILTER_VALIDATE_EMAIL); + } + + return $valid; + } + /** * Checks if it has to wait until the sending of the next */