Example #1
0
 /**
  * @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');
     }
     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;
 }