/** * @todo add port settings */ public function send($EventName = '') { $this->formatMessage($this->emailTemplate->toString()); $this->fireEvent('BeforeSendMail'); if (c('Garden.Email.Disabled')) { return; } if (c('Garden.Email.UseSmtp')) { $this->PhpMailer->isSMTP(); $SmtpHost = c('Garden.Email.SmtpHost', ''); $SmtpPort = c('Garden.Email.SmtpPort', 25); if (strpos($SmtpHost, ':') !== false) { list($SmtpHost, $SmtpPort) = explode(':', $SmtpHost); } $this->PhpMailer->Host = $SmtpHost; $this->PhpMailer->Port = $SmtpPort; $this->PhpMailer->SMTPSecure = c('Garden.Email.SmtpSecurity', ''); $this->PhpMailer->Username = $Username = c('Garden.Email.SmtpUser', ''); $this->PhpMailer->Password = $Password = c('Garden.Email.SmtpPassword', ''); if (!empty($Username)) { $this->PhpMailer->SMTPAuth = true; } } else { $this->PhpMailer->isMail(); } if ($EventName != '') { $this->EventArguments['EventName'] = $EventName; $this->fireEvent('SendMail'); } if (!empty($this->Skipped) && $this->PhpMailer->countRecipients() == 0) { // We've skipped all recipients. return true; } $this->PhpMailer->throwExceptions(true); if (!$this->PhpMailer->send()) { throw new Exception($this->PhpMailer->ErrorInfo); } return true; }