/** * @todo add port settings */ public function Send($EventName = '') { if (Gdn::Config('Garden.Email.UseSmtp')) { $this->PhpMailer->IsSMTP(); $SmtpHost = Gdn::Config('Garden.Email.SmtpHost', ''); $SmtpPort = Gdn::Config('Garden.Email.SmtpPort', 25); if (strpos($SmtpHost, ':') !== FALSE) { list($SmtpHost, $SmtpPort) = explode(':', $SmtpHost); } $this->PhpMailer->Host = $SmtpHost; $this->PhpMailer->Port = $SmtpPort; $this->PhpMailer->SMTPSecure = Gdn::Config('Garden.Email.SmtpSecurity', ''); $this->PhpMailer->Username = $Username = Gdn::Config('Garden.Email.SmtpUser', ''); $this->PhpMailer->Password = $Password = Gdn::Config('Garden.Email.SmtpPassword', ''); if (!empty($Username)) { $this->PhpMailer->SMTPAuth = TRUE; } } else { $this->PhpMailer->IsMail(); } if ($EventName != '') { $this->EventArguments['EventName'] = $EventName; $this->FireEvent('SendMail'); } $this->PhpMailer->ThrowExceptions(TRUE); if (!$this->PhpMailer->Send()) { throw new Exception($this->PhpMailer->ErrorInfo); } return true; }
/** * @todo add port settings */ public function Send($EventName = '') { $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; }