Example #1
0
 public function SendMessage()
 {
     // Set debug mode
     //QEmailServer::$TestMode = true;
     //QEmailServer::$TestModeDirectory = __DOCROOT__ . '/../file_assets/emails';
     QEmailServer::$SmtpServer = SMTP_SERVER;
     // Create a new message
     // Note that you can list multiple addresses and that Qcodo supports Bcc and Cc
     if ($this->objPrayerRequest) {
         $objMessage = new QEmailMessage();
         $objMessage->From = 'info@alcf.net <*****@*****.**>';
         $objMessage->To = $this->objPrayerRequest->Email;
         $objMessage->Subject = $this->txtSubject->Text;
         // Setup Plaintext Message
         $strBody = "Dear " . $this->objPrayerRequest->Name . ",\r\n\r\n";
         $strBody .= sprintf("Someone has sent you a note of encouragement regarding your prayer request.");
         $strBody .= sprintf("\r\nYou can view their note below.");
         $strBody .= '\\r\\nRegards, \\r\\nALCF Communications\\r\\n\\r\\n';
         $strBody .= $this->txtNote->Text;
         $objMessage->Body = $strBody;
         // Also setup HTML message (optional)
         $strBody = "Dear " . $this->objPrayerRequest->Name . ',<br/><br/>';
         $strBody .= sprintf("Someone has sent you a note of encouragement regarding your prayer request.");
         $strBody .= sprintf("<br>You can view their note below.");
         $strBody .= '<br>Regards,<br/><b>ALCF Communications</b><br><br>';
         $strBody .= '<p>' . $this->txtNote->Text . '</p>';
         $objMessage->HtmlBody = $strBody;
         // Add random/custom email headers
         $objMessage->SetHeader('x-application', 'Communications Team');
         QEmailServer::Send($objMessage);
         return 1;
     } else {
         return 0;
     }
 }
 public function Validate()
 {
     if (!parent::Validate()) {
         return false;
     }
     if (strlen(trim($this->strText)) && !QEmailServer::IsEmailValid($this->strText)) {
         $this->strValidationError = $this->strLabelForInvalid;
         return false;
     }
     $this->strValidationError = '';
     return true;
 }
Example #3
0
 public function Send()
 {
     $objMessage = new QEmailMessage();
     $objMessage->From = $this->FromAddress;
     $objMessage->To = $this->ToAddress;
     $objMessage->Subject = $this->Subject;
     $objMessage->Body = $this->Body;
     $objMessage->HtmlBody = $this->Html;
     try {
         QEmailServer::Send($objMessage);
         $this->Delete();
     } catch (QCallerException $objExc) {
         $this->ErrorMessage = $objExc->getMessage();
         $this->ErrorFlag = true;
         $this->Save();
     }
 }
 public function Validate()
 {
     if (parent::Validate()) {
         if (strlen(trim($this->strText))) {
             // RegExp taken from php.net
             $this->strText = trim($this->strText);
             $strEmailAddressArray = QEmailServer::GetEmailAddresses($this->strText);
             if (count($strEmailAddressArray) != 1 || strtolower($strEmailAddressArray[0]) != strtolower($this->strText)) {
                 $this->strValidationError = "Invalid e-mail address";
                 return false;
             }
         }
     } else {
         return false;
     }
     $this->strValidationError = "";
     return true;
 }
Example #5
0
 public function Send()
 {
     if (!$this->blnErrorFlag) {
         $this->blnErrorFlag = true;
         $this->Save();
         $objEmailMessage = new QEmailMessage($this->strFromAddress, $this->strToAddress, $this->strSubject, $this->strBody);
         $objEmailMessage->Cc = $this->strCcAddress;
         $objEmailMessage->Bcc = $this->strBccAddress;
         try {
             QEmailServer::Send($objEmailMessage);
         } catch (QCallerException $objExc) {
             QLog::Log('Email Failed to Send #' . $this->intId);
             QLog::Log($objExc->getMessage());
             $this->strErrorMessage = $objExc->getMessage();
             $this->Save();
         }
         $this->Delete();
     }
 }
Example #6
0
 public function Send()
 {
     // Do **NOT** send again if it has already been sent!
     if ($this->dttDateSent) {
         return;
     }
     // Store an array of email addresses (SMS-based) to send to
     $strBccArray = array();
     // Get the Group, and get the array for CcArray
     $intPersonIdArray = array();
     foreach ($this->Group->GetActiveGroupParticipationArray() as $objGroupParticipation) {
         // ONly at most one per person
         if (!array_key_exists($objGroupParticipation->PersonId, $intPersonIdArray)) {
             // Get the Person
             $objPerson = $objGroupParticipation->Person;
             // Do we have an SMS?
             if ($objPhone = $objPerson->GetSmsEnabledPhone()) {
                 // Yep!  Add it to the list
                 $strBccArray[] = $objPhone->SmsEmailAddress;
             }
             // Finally, let's make sure it only gets sent (at most) once per person
             $intPersonIdArray[$objGroupParticipation->PersonId] = $objGroupParticipation->PersonId;
         }
     }
     // Do we have any to send to?
     if (count($strBccArray)) {
         // Yes -- let's send it
         $objEmailMessage = new QEmailMessage($this->Login->Email, $this->Login->Email, $this->strSubject, $this->strBody);
         $objEmailMessage->Bcc = implode(', ', $strBccArray);
         QEmailServer::Send($objEmailMessage);
         $this->DateSent = QDateTime::Now();
         $this->Save();
     } else {
         // No -- let's report it
         $objEmailMessage = new QEmailMessage($this->Login->Email, $this->Login->Email, '[Failed to Send] ' . $this->strSubject, 'The following SMS did NOT send because there were no SMS-enabled group participants: ' . $this->strBody);
         QEmailServer::Send($objEmailMessage);
         $this->Delete();
     }
 }
 public function btnRecoverPassword_Click($strFormId, $strControlId, $strParameter)
 {
     if ($this->txtEmail->Text) {
         $objUser = NarroUser::QuerySingle(QQ::Equal(QQN::NarroUser()->Email, $this->txtEmail->Text));
     } elseif ($this->txtUsername->Text) {
         $objUser = NarroUser::QuerySingle(QQ::Equal(QQN::NarroUser()->Username, $this->txtUsername->Text));
     } else {
         $this->lblMessage->ForeColor = 'red';
         $this->lblMessage->Text = t('Please enter a username or email to continue.');
         return false;
     }
     if ($objUser instanceof NarroUser) {
         if ($objUser->UserId == NarroUser::ANONYMOUS_USER_ID) {
             $this->lblMessage->ForeColor = 'red';
             $this->lblMessage->Text = t('Hey, the anonymous user doesn\'t have a password. What are you trying to do?');
             return false;
         }
         $objMessage = new QEmailMessage();
         $objMessage->From = sprintf('%s <%s>', __FROM_EMAIL_NAME__, __FROM_EMAIL_ADDRESS__);
         $objMessage->To = sprintf('%s <%s>', $objUser->Username, $objUser->Email);
         $objMessage->Subject = sprintf('Password recovery for "%s" on "%s"', $objUser->Username, $_SERVER['HTTP_HOST']);
         $objMessage->Body = sprintf('Somebody, probably you, requested a password recovery for "%s" on "%s". To change your password, please follow this link: %s', $objUser->Username, $_SERVER['HTTP_HOST'], (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__ . sprintf('/change_password.php?l=%s&u=%s&h=%s', QApplication::$TargetLanguage->LanguageCode, $objUser->Username, $objUser->Password));
         try {
             QEmailServer::Send($objMessage);
             $this->lblMessage->ForeColor = 'green';
             $this->lblMessage->Text = t('You should have a new email message with instructions. Check your spam/bulk directory too.');
         } catch (Exception $objEx) {
             $this->lblMessage->ForeColor = 'red';
             $this->lblMessage->Text = t('Failed to send email. This may be a server issue. Please try again later.');
             return false;
         }
     } else {
         $this->lblMessage->ForeColor = 'red';
         $this->lblMessage->Text = t('Bad username or/and email');
     }
 }
Example #8
0
<?php

$objEmailCursor = Email::QueryCursor(QQ::All());
while ($objEmail = Email::InstantiateCursor($objEmailCursor)) {
    if (!QEmailServer::IsEmailValid($objEmail->Address)) {
        printf("%s - %s Id #%s\r\n", $objEmail->Address, $objEmail->Person->Name, $objEmail->PersonId);
    }
}
Example #9
0
 /**
  * Sends a message out via SMTP according to the server, ip, etc. preferences
  * as set up on the class.  Takes in a QEmailMessage object.
  *
  * Will throw a QEmailException exception on any error.
  *
  * @param QEmailMessage $objMessage Message to Send
  * @return void
  */
 public static function Send(QEmailMessage $objMessage)
 {
     $objResource = null;
     if (QEmailServer::$TestMode) {
         // Open up a File Resource to the TestModeDirectory
         $strArray = explode(' ', microtime());
         $strFileName = sprintf('%s/email_%s%s.txt', QEmailServer::$TestModeDirectory, $strArray[1], substr($strArray[0], 1));
         $objResource = fopen($strFileName, 'w');
         if (!$objResource) {
             throw new QEmailException(sprintf('Unable to open Test SMTP connection to: %s', $strFileName));
         }
         // Clear the Read Buffer
         if (!feof($objResource)) {
             fgets($objResource, 4096);
         }
         // Write the Connection Command
         fwrite($objResource, sprintf("telnet %s %s\r\n", QEmailServer::$SmtpServer, QEmailServer::$SmtpPort));
     } else {
         $objResource = fsockopen(QEmailServer::$SmtpServer, QEmailServer::$SmtpPort);
         if (!$objResource) {
             throw new QEmailException(sprintf('Unable to open SMTP connection to: %s %s', QEmailServer::$SmtpServer, QEmailServer::$SmtpPort));
         }
     }
     // Connect
     $strResponse = null;
     if (!QEmailServer::$TestMode && !feof($objResource)) {
         $strResponse = fgets($objResource, 4096);
         // Iterate through all "220-" responses (stop at "220 ")
         while (substr($strResponse, 0, 3) == "220" && substr($strResponse, 0, 4) != "220 ") {
             if (!feof($objResource)) {
                 $strResponse = fgets($objResource, 4096);
             }
         }
         // Check for a "220" response
         if (strpos($strResponse, "220") === false || strpos($strResponse, "220") != 0) {
             throw new QEmailException(sprintf('Error Response on Connect: %s', $strResponse));
         }
     }
     // Send: EHLO
     fwrite($objResource, sprintf("EHLO %s\r\n", QEmailServer::$OriginatingServerIp));
     if (!QEmailServer::$TestMode && !feof($objResource)) {
         $strResponse = fgets($objResource, 4096);
         // Iterate through all "250-" responses (stop at "250 ")
         while (substr($strResponse, 0, 3) == "250" && substr($strResponse, 0, 4) != "250 ") {
             if (!feof($objResource)) {
                 $strResponse = fgets($objResource, 4096);
             }
         }
         // Check for a "250" response
         if (strpos($strResponse, "250") === false || strpos($strResponse, "250") != 0) {
             throw new QEmailException(sprintf('Error Response on EHLO: %s', $strResponse));
         }
     }
     // Send Authentication
     if (QEmailServer::$AuthPlain) {
         fwrite($objResource, "AUTH PLAIN " . base64_encode(QEmailServer::$SmtpUsername . "" . QEmailServer::$SmtpUsername . "" . QEmailServer::$SmtpPassword) . "\r\n");
         if (!QEmailServer::$TestMode && !feof($objResource)) {
             $strResponse = fgets($objResource, 4096);
             if (strpos($strResponse, "235") === false || strpos($strResponse, "235") != 0) {
                 throw new QEmailException(sprintf('Error in response from AUTH PLAIN: %s', $strResponse));
             }
         }
     }
     if (QEmailServer::$AuthLogin) {
         fwrite($objResource, "AUTH LOGIN\r\n");
         if (!QEmailServer::$TestMode && !feof($objResource)) {
             $strResponse = fgets($objResource, 4096);
             if (strpos($strResponse, "334") === false || strpos($strResponse, "334") != 0) {
                 throw new QEmailException(sprintf('Error in response from AUTH LOGIN: %s', $strResponse));
             }
         }
         fwrite($objResource, base64_encode(QEmailServer::$SmtpUsername) . "\r\n");
         if (!QEmailServer::$TestMode && !feof($objResource)) {
             $strResponse = fgets($objResource, 4096);
             if (strpos($strResponse, "334") === false || strpos($strResponse, "334") != 0) {
                 throw new QEmailException(sprintf('Error in response from AUTH LOGIN: %s', $strResponse));
             }
         }
         fwrite($objResource, base64_encode(QEmailServer::$SmtpPassword) . "\r\n");
         if (!QEmailServer::$TestMode && !feof($objResource)) {
             $strResponse = fgets($objResource, 4096);
             if (strpos($strResponse, "235") === false || strpos($strResponse, "235") != 0) {
                 throw new QEmailException(sprintf('Error in response from AUTH LOGIN: %s', $strResponse));
             }
         }
     }
     // Setup MAIL FROM line
     $strAddressArray = QEmailServer::GetEmailAddresses($objMessage->From);
     if (count($strAddressArray) != 1) {
         throw new QEmailException(sprintf('Not a valid From address: %s', $objMessage->From));
     }
     // Send: MAIL FROM line
     fwrite($objResource, sprintf("MAIL FROM: <%s>\r\n", $strAddressArray[0]));
     if (!QEmailServer::$TestMode && !feof($objResource)) {
         $strResponse = fgets($objResource, 4096);
         // Check for a "250" response
         if (strpos($strResponse, "250") === false || strpos($strResponse, "250") != 0) {
             throw new QEmailException(sprintf('Error Response on MAIL FROM: %s', $strResponse));
         }
     }
     // Setup RCPT TO line(s)
     $strAddressToArray = QEmailServer::GetEmailAddresses($objMessage->To);
     if (!$strAddressToArray) {
         throw new QEmailException(sprintf('Not a valid To address: %s', $objMessage->To));
     }
     $strAddressCcArray = QEmailServer::GetEmailAddresses($objMessage->Cc);
     if (!$strAddressCcArray) {
         $strAddressCcArray = array();
     }
     $strAddressBccArray = QEmailServer::GetEmailAddresses($objMessage->Bcc);
     if (!$strAddressBccArray) {
         $strAddressBccArray = array();
     }
     $strAddressCcBccArray = array_merge($strAddressCcArray, $strAddressBccArray);
     $strAddressArray = array_merge($strAddressToArray, $strAddressCcBccArray);
     // Send: RCPT TO line(s)
     foreach ($strAddressArray as $strAddress) {
         fwrite($objResource, sprintf("RCPT TO: <%s>\r\n", $strAddress));
         if (!QEmailServer::$TestMode && !feof($objResource)) {
             $strResponse = fgets($objResource, 4096);
             // Check for a "250" response
             if (strpos($strResponse, "250") === false || strpos($strResponse, "250") != 0) {
                 throw new QEmailException(sprintf('Error Response on RCPT TO: %s', $strResponse));
             }
         }
     }
     // Send: DATA
     fwrite($objResource, "DATA\r\n");
     if (!QEmailServer::$TestMode && !feof($objResource)) {
         $strResponse = fgets($objResource, 4096);
         // Check for a "354" response
         if (strpos($strResponse, "354") === false || strpos($strResponse, "354") != 0) {
             throw new QEmailException(sprintf('Error Response on DATA: %s', $strResponse));
         }
     }
     // Send: Required Headers
     fwrite($objResource, sprintf("Date: %s\r\n", QDateTime::NowToString(QDateTime::FormatRfc822)));
     fwrite($objResource, sprintf("To: %s\r\n", $objMessage->To));
     fwrite($objResource, sprintf("From: %s\r\n", $objMessage->From));
     // Send: Optional Headers
     if ($objMessage->Subject) {
         fwrite($objResource, sprintf("Subject: %s\r\n", $objMessage->Subject));
     }
     if ($objMessage->Cc) {
         fwrite($objResource, sprintf("Cc: %s\r\n", $objMessage->Cc));
     }
     // Send: Content-Type Header (if applicable)
     $semi_random = md5(time());
     $strBoundary = sprintf('==qcodo_qemailserver_multipart_boundary____x%sx', $semi_random);
     // Send: Other Headers (if any)
     foreach ($objArray = $objMessage->HeaderArray as $strKey => $strValue) {
         fwrite($objResource, sprintf("%s: %s\r\n", $strKey, $strValue));
     }
     // if we are adding an html or files to the message we need these headers.
     if ($objMessage->HasFiles || $objMessage->HtmlBody) {
         fwrite($objResource, "MIME-Version: 1.0\r\n");
         fwrite($objResource, sprintf("Content-Type: multipart/mixed;\r\n boundary=\"%s\"\r\n", $strBoundary));
         fwrite($objResource, sprintf("This is a multipart message in MIME format.\r\n\r\n", $strBoundary));
         fwrite($objResource, sprintf("--%s\r\n", $strBoundary));
     }
     $strAltBoundary = sprintf('==qcodo_qemailserver_alternative_boundary____x%sx', $semi_random);
     // Send: Body
     // Setup Encoding Type (use QEmailServer if specified, otherwise default to QApplication's)
     if (!($strEncodingType = QEmailServer::$EncodingType)) {
         $strEncodingType = QApplication::$EncodingType;
     }
     if ($objMessage->HtmlBody) {
         fwrite($objResource, sprintf("Content-Type: multipart/alternative;\r\n boundary=\"%s\"\r\n\r\n", $strAltBoundary));
         fwrite($objResource, sprintf("--%s\r\n", $strAltBoundary));
         fwrite($objResource, sprintf("Content-Type: text/plain; charset=\"%s\"\r\n", $strEncodingType));
         fwrite($objResource, sprintf("Content-Transfer-Encoding: 7bit\r\n\r\n"));
         fwrite($objResource, $objMessage->Body);
         fwrite($objResource, "\r\n\r\n");
         fwrite($objResource, sprintf("--%s\r\n", $strAltBoundary));
         fwrite($objResource, sprintf("Content-Type: text/html; charset=\"%s\"\r\n", $strEncodingType));
         //				fwrite($objResource, sprintf("Content-Transfer-Encoding: quoted-printable\r\n\r\n"));
         fwrite($objResource, sprintf("Content-Transfer-Encoding: 7bit\r\n\r\n"));
         fwrite($objResource, $objMessage->HtmlBody);
         fwrite($objResource, "\r\n\r\n");
         fwrite($objResource, sprintf("--%s--\r\n", $strAltBoundary));
     } elseif ($objMessage->HasFiles) {
         fwrite($objResource, sprintf("Content-Type: multipart/alternative;\r\n boundary=\"%s\"\r\n\r\n", $strAltBoundary));
         fwrite($objResource, sprintf("--%s\r\n", $strAltBoundary));
         fwrite($objResource, sprintf("Content-Type: text/plain; charset=\"%s\"\r\n", $strEncodingType));
         fwrite($objResource, sprintf("Content-Transfer-Encoding: 7bit\r\n\r\n"));
         fwrite($objResource, $objMessage->Body);
         fwrite($objResource, "\r\n\r\n");
         fwrite($objResource, sprintf("--%s--\r\n", $strAltBoundary));
     } else {
         fwrite($objResource, sprintf("Content-Type: text/plain; charset=\"%s\"\r\n", $strEncodingType));
         fwrite($objResource, sprintf("Content-Transfer-Encoding: 7bit\r\n\r\n"));
         fwrite($objResource, "\r\n" . $objMessage->Body);
     }
     // Send: File Attachments
     if ($objMessage->HasFiles) {
         foreach ($objArray = $objMessage->FileArray as $objFile) {
             fwrite($objResource, sprintf("--%s\r\n", $strBoundary));
             fwrite($objResource, sprintf("Content-Type: %s;\r\n", $objFile->MimeType));
             fwrite($objResource, sprintf("      name=\"%s\"\r\n", $objFile->FileName));
             fwrite($objResource, "Content-Transfer-Encoding: base64\r\n");
             fwrite($objResource, sprintf("Content-Length: %s\r\n", strlen($objFile->EncodedFileData)));
             fwrite($objResource, "Content-Disposition: attachment;\r\n");
             fwrite($objResource, sprintf("      filename=\"%s\"\r\n\r\n", $objFile->FileName));
             fwrite($objResource, $objFile->EncodedFileData);
             //					foreach (explode("\n", $objFile->EncodedFileData) as $strLine) {
             //						$strLine = trim($strLine);
             //						fwrite($objResource, $strLine . "\r\n");
             //					}
         }
     }
     // close a message with these boundaries if the message had files or had html
     if ($objMessage->HasFiles || $objMessage->HtmlBody) {
         fwrite($objResource, sprintf("\r\n\r\n--%s--\r\n", $strBoundary));
     }
     // send end of file attachments...
     // Send: Message End
     fwrite($objResource, "\r\n.\r\n");
     if (!QEmailServer::$TestMode && !feof($objResource)) {
         $strResponse = fgets($objResource, 4096);
         // Check for a "250" response
         if (strpos($strResponse, "250") === false || strpos($strResponse, "250") != 0) {
             throw new QEmailException(sprintf('Error Response on MAIL FROM: %s', $strResponse));
         }
     }
     // Send: QUIT
     fwrite($objResource, "QUIT\r\n");
     if (!feof($objResource)) {
         $strResponse = fgets($objResource, 4096);
     }
     // Close the Resource
     fclose($objResource);
 }
Example #10
0
 public function SendMessage()
 {
     // Set debug mode
     //QEmailServer::$TestMode = true;
     //QEmailServer::$TestModeDirectory = __DOCROOT__ . '/../file_assets/emails';
     QEmailServer::$SmtpServer = SMTP_SERVER;
     // Create a new message
     // Note that you can list multiple addresses and that Qcodo supports Bcc and Cc
     $objMessage = new QEmailMessage();
     $objMessage->From = 'info@alcf.net <*****@*****.**>';
     $objMessage->To = $this->txtEmail->Text;
     $objMessage->Subject = 'Your Praise testimony has been successfuly submitted.';
     // Setup Plaintext Message
     $strBody = "Dear " . $this->txtName->Text . ",\r\n\r\n";
     $strBody .= sprintf("You have successfully submitted your praise testimony.");
     $strBody .= sprintf("\r\nYou can view your praise testimony by selecting the 'Praises and Thanks' button in the prayer room.");
     $strBody .= '\\r\\nRegards, \\r\\nALCF Communications';
     $objMessage->Body = $strBody;
     // Also setup HTML message (optional)
     $strBody = "Dear " . $this->txtName->Text . ',<br/><br/>';
     $strBody .= sprintf("You have successfully submitted your praise testimony.");
     $strBody .= sprintf("<br>You can view your praise testimony by selecting the 'Praises and Thanks' button in the prayer room.");
     $strBody .= '<br>Regards,<br/><b>ALCF Communications</b>';
     $objMessage->HtmlBody = $strBody;
     // Add random/custom email headers
     $objMessage->SetHeader('x-application', 'Communications Team');
     QEmailServer::Send($objMessage);
 }
Example #11
0
 public function testInIsEmailValidTest_UnpartneredSquareBracketIp()
 {
     $this->assertFalse(QEmailServer::IsEmailValid('test@[123.123.123.123'));
     $this->assertFalse(QEmailServer::IsEmailValid('test@123.123.123.123]'));
 }
Example #12
0
 /**
  * Uses SendRawMessage to sends a message out via SMTP according to the server, ip, etc. preferences
  * as set up on the class.  Takes in a QEmailMessage object to calculate the appropriate fields
  * to SendRawMesage.
  *
  * Will throw a QEmailException exception on any error.
  *
  * @param QEmailMessage $objMessage Message to Send
  * @return void
  */
 public static function Send(QEmailMessage $objMessage)
 {
     // Set Up Fields
     $strAddressArray = QEmailServer::GetEmailAddresses($objMessage->From);
     if (count($strAddressArray) != 1) {
         throw new QEmailException(sprintf('Not a valid From address: %s', $objMessage->From));
     }
     $strMailFrom = $strAddressArray[0];
     // Setup RCPT TO Addresses
     $strAddressToArray = QEmailServer::GetEmailAddresses($objMessage->To);
     if (!$strAddressToArray || !count($strAddressToArray)) {
         throw new QEmailException(sprintf('Not a valid To address: %s', $objMessage->To));
     }
     $strAddressCcArray = QEmailServer::GetEmailAddresses($objMessage->Cc);
     if (!$strAddressCcArray) {
         $strAddressCcArray = array();
     }
     $strAddressBccArray = QEmailServer::GetEmailAddresses($objMessage->Bcc);
     if (!$strAddressBccArray) {
         $strAddressBccArray = array();
     }
     $strAddressCcBccArray = array_merge($strAddressCcArray, $strAddressBccArray);
     $strRcptToArray = array_merge($strAddressToArray, $strAddressCcBccArray);
     $strMessageArray = $objMessage->CalculateMessageHeaderAndBody(self::$EncodingType);
     self::SendRawMessage($strMailFrom, $strRcptToArray, $strMessageArray[0], $strMessageArray[1]);
 }
Example #13
0
 /**
  * Given the "To" and "Cc" in the header, create an array of Email Addresses that should be looked up
  * @return string[]
  */
 protected function CalculateEmailArray()
 {
     $strTo = $this->GetHeaderValue('To') . ', ' . $this->GetHeaderValue('Cc') . ', ' . $this->GetHeaderValue('TO') . ', ' . $this->GetHeaderValue('CC') . ', ' . $this->GetHeaderValue('to') . ', ' . $this->GetHeaderValue('cc');
     $strArrayToReturn = array();
     $strArrayToCheck = QEmailServer::GetEmailAddresses($strTo);
     if ($strArrayToCheck) {
         foreach ($strArrayToCheck as $strEmailAddress) {
             $strEmailAddress = strtolower($strEmailAddress);
             if (strpos($strEmailAddress, '@groups.alcf.net')) {
                 $strArrayToReturn[$strEmailAddress] = $strEmailAddress;
             }
         }
     }
     return $strArrayToReturn;
 }
Example #14
0
 public function SendMessage()
 {
     // Set debug mode
     //QEmailServer::$TestMode = true;
     //QEmailServer::$TestModeDirectory = __DOCROOT__ . '/../file_assets/emails';
     QEmailServer::$SmtpServer = SMTP_SERVER;
     // Create a new message
     // Note that you can list multiple addresses and that Qcodo supports Bcc and Cc
     $objMessage = new QEmailMessage();
     $objMessage->From = 'Carisa Hamilton <*****@*****.**>';
     $objMessage->To = $this->objGroupRegistration->Email;
     $objMessage->Bcc = '*****@*****.**';
     $objMessage->Subject = 'Invitation to Growth Groups';
     // Setup Plaintext Message
     $strBody = "Hello " . $this->objGroupRegistration->FirstName . "!\r\n\r\n";
     $strBody .= 'We are very excited that you are interested in facilitating a Growth Group! \\r\\nAttached is a ' . 'facilitator application we ask all potential facilitators to complete. \\r\\n' . 'Please fill it out and send it back to me via email (carisa.hamilton@alcf.net). \\r\\nYou may also fax ' . 'it to the church office at 650-625-1500 or drop it off in the All Forms Box at the worship ' . 'center. \\r\\nOnce we receive your application, Pastor John will follow up with you for a short ' . 'interview.\\r\\n';
     $strBody .= 'If you have any questions or concerns please feel free to contact me.\\r\\n\\r\\n';
     $strBody .= 'Blessings,\\r\\n Carisa';
     $objMessage->Body = $strBody;
     // Also setup HTML message (optional)
     $strBody = "Hello " . $this->objGroupRegistration->FirstName . "!<br><br>";
     $strBody .= 'We are very excited that you are interested in facilitating a Growth Group! <br>Attached is a ' . 'facilitator application we ask all potential facilitators to complete. <br>' . 'Please fill it out and send it back to me via email (carisa.hamilton@alcf.net). <br>You may also fax ' . 'it to the church office at 650-625-1501 or drop it off in the All Forms Box at the worship ' . 'center. <br>Once we receive your application, Pastor John will follow up with you for a short ' . 'interview.<br><br>';
     $strBody .= 'If you have any questions or concerns please feel free to contact me.<br><br>';
     $strBody .= 'Blessings,<br> Carisa';
     $objMessage->HtmlBody = $strBody;
     // Add the attachment
     $objFile = new QEmailAttachment(__DOCROOT__ . '/../file_assets/FacilitatorApplication.doc');
     $objMessage->AddAttachment($objFile);
     // Add random/custom email headers
     $objMessage->SetHeader('x-application', 'Growth Groups Ministry');
     QEmailServer::Send($objMessage);
 }
Example #15
0
 public function SendNotification()
 {
     $objPerson = Person::Load($this->objPersonId);
     $email = '';
     if ($objPerson->PrimaryEmail->Address) {
         $email = $objPerson->PrimaryEmail->Address;
     } else {
         $email = $objPerson->_Email->Address;
     }
     // Set debug mode
     //QEmailServer::$TestMode = true;
     //QEmailServer::$TestModeDirectory = __DOCROOT__ . '/../file_assets/emails';
     QEmailServer::$SmtpServer = SMTP_SERVER;
     // Create a new message
     // Note that you can list multiple addresses and that Qcodo supports Bcc and Cc
     $objMessage = new QEmailMessage();
     $objMessage->From = 'Christina Alo <*****@*****.**>';
     $objMessage->To = 'Christina <*****@*****.**>';
     $objMessage->Subject = 'Notification of Exiting Members';
     // Setup Plaintext Message
     $strBody = "Hello Administrator (Christina)!\r\n\r\n";
     $strBody .= 'r\\n';
     $strBody .= 'Someone just unsubscribed from the church newsletter and closed their membership.\\r\\n\\r\\n';
     $strBody .= sprintf("Their Details:\r\n%s %s\r\nemail: %s \r\n\r\n", $objPerson->FirstName, $objPerson->LastName, $email);
     $strBody .= 'Blessings,\\r\\n Noah.';
     $objMessage->Body = $strBody;
     // Also setup HTML message (optional)
     $strBody = "Hello Administrator (Christina)!<br><br>";
     $strBody .= 'Someone just unsubscribed from the church newsletter and closed their membership.<br><br>';
     $strBody .= sprintf("Their Details:<br>%s %s<br>email: %s<br><br>", $objPerson->FirstName, $objPerson->LastName, $email);
     $strBody .= 'Blessings,<br> Noah.';
     $objMessage->HtmlBody = $strBody;
     // Add random/custom email headers
     $objMessage->SetHeader('x-application', 'Church Newsletter Administration');
     QEmailServer::Send($objMessage);
 }
Example #16
0
 public function SendMessage()
 {
     // Set debug mode
     //QEmailServer::$TestMode = true;
     //QEmailServer::$TestModeDirectory = __DOCROOT__ . '/../file_assets/emails';
     QEmailServer::$SmtpServer = SMTP_SERVER;
     // Create a new message
     // Note that you can list multiple addresses and that Qcodo supports Bcc and Cc
     $objMessage = new QEmailMessage();
     $objMessage->From = 'info@alcf.net <*****@*****.**>';
     $objMessage->To = 'geraldine.hill@alcf.net  <*****@*****.** >';
     // send to prayer team
     $objMessage->Subject = 'A Confidential Prayer Request was submitted.';
     // Setup Plaintext Message
     $strBody = "Dear Prayer Team,\r\n\r\n";
     $strBody .= sprintf("The following confidential prayer request was submitted:\r\n");
     $strBody .= sprintf($this->txtContent->Text . '\\r\\n');
     $strBody .= '\\r\\nRegards, \\r\\nALCF Communications';
     $objMessage->Body = $strBody;
     // Also setup HTML message (optional)
     $strBody = "Dear Prayer Team,<br/><br/>";
     $strBody .= sprintf("The following confidential prayer request was submitted:<br>");
     $strBody .= sprintf($this->txtContent->Text . "<br>");
     $strBody .= '<br>Regards,<br/><b>ALCF Communications</b>';
     $objMessage->HtmlBody = $strBody;
     // Add random/custom email headers
     $objMessage->SetHeader('x-application', 'Communications Team');
     QEmailServer::Send($objMessage);
 }
Example #17
0
 public function SendMessage()
 {
     // Set debug mode
     //QEmailServer::$TestMode = true;
     //QEmailServer::$TestModeDirectory = __DOCROOT__ . '/../file_assets/emails';
     QEmailServer::$SmtpServer = SMTP_SERVER;
     // Create a new message
     // Note that you can list multiple addresses and that Qcodo supports Bcc and Cc
     $objMessage = new QEmailMessage();
     $objMessage->From = 'info@alcf.net <*****@*****.**>';
     $objMessage->To = $this->txtEmail->Text;
     $objMessage->Subject = 'Your Prayer Request has been successfuly submitted.';
     // Setup Plaintext Message
     $strBody = "Dear " . $this->txtName->Text . ",\r\n\r\n";
     $strBody .= sprintf("You have successfully submitted your prayer request.");
     $strBody .= sprintf("\r\nYou can view your prayer request by selecting the 'View Non-confidential prayer requests' button in the prayer room.");
     $strBody .= sprintf("\r\nIf you selected to view whenever anyone prays for you, you should be able to see the number of people who have prayed for you by observing the indicator when viewing your prayer details.");
     $strBody .= '\\r\\nRegards, \\r\\nALCF Communications';
     $objMessage->Body = $strBody;
     // Also setup HTML message (optional)
     $strBody = "Dear " . $this->txtName->Text . ',<br/><br/>';
     $strBody .= sprintf("You have successfully submitted your prayer request.");
     $strBody .= sprintf("<br>You can view your prayer request by selecting the 'View Non-confidential prayer requests' button in the prayer room.");
     $strBody .= sprintf("<br>If you selected to view whenever anyone prays for you, you should be able to see the number of people who have prayed for you by observing the indicator when viewing your prayer details.");
     $strBody .= '<br>Regards,<br/><b>ALCF Communications</b>';
     $objMessage->HtmlBody = $strBody;
     // Add random/custom email headers
     $objMessage->SetHeader('x-application', 'Communications Team');
     QEmailServer::Send($objMessage);
 }
Example #18
0
		email capability without actually sending out any emails.<br/><br/>

		Feel free to View Source the code.  Note that the final <b>Send</b> call is
		commented out, so this page is actually non-functional.  But you can view the
		code to get a sense as to how the <b>QEmailServer</b> and its associated
		<b>QEmailMessage</b> class work.
	</div>
	
	For obvious reasons, this page is non-functional.  To view the commented out source,
	please click on <b>View Source</b> at the top right of the page.

<?php 
// We want to define our email SMTP server (it defaults to "localhost")
// This would typically be done in prepend.inc, and its value should probably be a constant
// that is defined in _configuration.inc
QEmailServer::$SmtpServer = 'mx.acme.com';
// Create a new message
// Note that you can list multiple addresses and that Qcodo supports Bcc and Cc
$objMessage = new QEmailMessage();
$objMessage->From = 'ACME Reporting Service <*****@*****.**>';
$objMessage->To = 'John Doe <*****@*****.**>, Jane Doe <*****@*****.**>';
$objMessage->Bcc = '*****@*****.**';
$objMessage->Subject = 'Report for ' . QDateTime::NowToString(QDateTime::FormatDisplayDate);
// Setup Plaintext Message
$strBody = "Dear John and Jane Doe,\r\n\r\n";
$strBody .= "You have new reports to review.  Please go to the ACME Portal at http://portal.acme.com/ to review.\r\n\r\n";
$strBody .= "Regards,\r\nACME Reporting Service";
$objMessage->Body = $strBody;
// Also setup HTML message (optional)
$strBody = 'Dear John and Jane Doe,<br/><br/>';
$strBody .= '<b>You have new reports to review.</b>  Please go to the <a href="http://portal.acme.com/">ACME Portal</a> to review.<br/><br/>';
 public function SendMessage()
 {
     $facilitatorList = array();
     $groupInfo = array();
     // Get information for each selected group
     foreach ($this->rbtnSelectArray as $rbtnSelect) {
         if ($rbtnSelect->Checked) {
             $objGroup = Group::Load($rbtnSelect->ActionParameter);
             $objGroupParticipants = GroupParticipation::LoadArrayByGroupId($objGroup->Id);
             $bFoundContact = false;
             // Check for Contact person first
             foreach ($objGroupParticipants as $objParticipant) {
                 if ($objParticipant->GroupRoleId == $this->intGroupContactRoleId && $objParticipant->DateEnd == null) {
                     $objContact = Person::Load($objParticipant->PersonId);
                     $facilitatorList[] = $objContact;
                     $bFoundContact = true;
                     break;
                 }
             }
             // If contact person not found, grab facilitator
             if (!$bFoundContact) {
                 foreach ($objGroupParticipants as $objParticipant) {
                     if ($objParticipant->GroupRoleId == $this->intFacilitatorRoleId && $objParticipant->DateEnd == null) {
                         $objFacilitator = Person::Load($objParticipant->PersonId);
                         $facilitatorList[] = $objFacilitator;
                         break;
                     }
                 }
             }
             $ggGroup = GrowthGroup::Load($rbtnSelect->ActionParameter);
             $groupInfo[] = array(trim(str_replace(range(0, 9), '', $objGroup->Name)), $ggGroup->MeetingInfo);
         }
     }
     // Set debug mode
     //QEmailServer::$TestMode = true;
     //QEmailServer::$TestModeDirectory = __DOCROOT__ . '/../file_assets/emails';
     QEmailServer::$SmtpServer = SMTP_SERVER;
     // Create a new message
     // Note that you can list multiple addresses and that Qcodo supports Bcc and Cc
     $objMessage = new QEmailMessage();
     $objMessage->From = 'Carisa Hamilton <*****@*****.**>';
     $objMessage->To = $this->objRegistrant->Email;
     $objMessage->Bcc = '*****@*****.**';
     $objMessage->Subject = 'Invitation to Growth Groups';
     // Setup Plaintext Message
     $strBody = "Dear " . $this->objRegistrant->FirstName . ",\r\n\r\n";
     $strBody .= "Thank you for your interest in Growth Groups! Below is the information for one or more Growth Groups in your area. Please contact the facilitators below for more information about visiting. I've copied them on this e-mail so that they will know of your interest.\r\n\r\n";
     $strBody .= sprintf("%s %s\r\n%s\r\n%s\r\n\r\n", $this->objRegistrant->FirstName, $this->objRegistrant->LastName, $this->objRegistrant->Phone, $this->objRegistrant->Email);
     if (count($groupInfo) >= 1) {
         if ($facilitatorList[0]->PrimaryEmailId == null) {
             $emailArray = Email::LoadArrayByPersonId($facilitatorList[0]->Id);
             $email = $emailArray[0]->Address;
             // just grab the first one we find
         } else {
             $email = Email::Load($facilitatorList[0]->PrimaryEmailId)->Address;
         }
         $strBody .= sprintf("%s, %s \r\\Contact: %s %s\r\n%s\r\n\r\n", $groupInfo[0][0], $groupInfo[0][1], $facilitatorList[0]->FirstName, $facilitatorList[0]->LastName, $email);
         $objMessage->Cc = $email;
     }
     if (count($groupInfo) >= 2) {
         if ($facilitatorList[1]->PrimaryEmailId == null) {
             $emailArray = Email::LoadArrayByPersonId($facilitatorList[1]->Id);
             $email = $emailArray[0]->Address;
             // just grab the first one we find
         } else {
             $email = Email::Load($facilitatorList[1]->PrimaryEmailId)->Address;
         }
         $strBody .= sprintf("%s, %s \r\\Contact: %s %s\r\n%s\r\n\r\n", $groupInfo[1][0], $groupInfo[1][1], $facilitatorList[1]->FirstName, $facilitatorList[1]->LastName, $email);
         $objMessage->Cc .= ', ' . $email;
     }
     if (count($groupInfo) >= 3) {
         if ($facilitatorList[1]->PrimaryEmailId == null) {
             $emailArray = Email::LoadArrayByPersonId($facilitatorList[2]->Id);
             $email = $emailArray[0]->Address;
             // just grab the first one we find
         } else {
             $email = Email::Load($facilitatorList[2]->PrimaryEmailId)->Address;
         }
         $strBody .= sprintf("%s, %s \r\\Contact: %s %s\r\n%s\r\n", $groupInfo[2][0], $groupInfo[2][1], $facilitatorList[2]->FirstName, $facilitatorList[2]->LastName, $email);
         $objMessage->Cc .= ', ' . $email;
     }
     $strBody .= '\\r\\n* Please don\'t hesitate to visit a group for 2 to 3 times before prayerfully deciding if the ' . 'group is a good fit for you.\\r\\n\\r\\n';
     $strBody .= 'Regards, \\r\\nCarisa Hamilton';
     $objMessage->Body = $strBody;
     // Also setup HTML message (optional)
     $strBody = "Dear " . $this->objRegistrant->FirstName . ',<br/><br/>';
     $strBody .= 'Thank you for your interest in Growth Groups! Below is the information for one or more Growth Groups ' . 'in your area. <br>Please contact the facilitators below for more information about visiting. ' . 'I have copied them on this e-mail so that they will know of your interest.<br><br>';
     $strBody .= sprintf("%s %s<br>%s<br>%s<br><br>", $this->objRegistrant->FirstName, $this->objRegistrant->LastName, $this->objRegistrant->Phone, $this->objRegistrant->Email);
     if (count($groupInfo) >= 1) {
         if ($facilitatorList[0]->PrimaryEmailId == null) {
             $emailArray = Email::LoadArrayByPersonId($facilitatorList[0]->Id);
             $email = $emailArray[0]->Address;
             // just grab the first one we find
         } else {
             $email = Email::Load($facilitatorList[0]->PrimaryEmailId)->Address;
         }
         $strBody .= sprintf("<b>Option 1</b><br>%s, %s<br>Contact: %s %s<br>%s<br><br>", $groupInfo[0][0], $groupInfo[0][1], $facilitatorList[0]->FirstName, $facilitatorList[0]->LastName, $email);
         $objMessage->Cc .= ', ' . $email;
     }
     if (count($groupInfo) >= 2) {
         if ($facilitatorList[1]->PrimaryEmailId == null) {
             $emailArray = Email::LoadArrayByPersonId($facilitatorList[1]->Id);
             $email = $emailArray[0]->Address;
             // just grab the first one we find
         } else {
             $email = Email::Load($facilitatorList[1]->PrimaryEmailId)->Address;
         }
         $strBody .= sprintf("<b>Option 2</b><br>%s, %s <br><b>Contact:</b> %s %s<br>%s<br><br>", $groupInfo[1][0], $groupInfo[1][1], $facilitatorList[1]->FirstName, $facilitatorList[1]->LastName, $email);
         $objMessage->Cc .= ', ' . $email;
     }
     if (count($groupInfo) >= 3) {
         if ($facilitatorList[1]->PrimaryEmailId == null) {
             $emailArray = Email::LoadArrayByPersonId($facilitatorList[2]->Id);
             $email = $emailArray[0]->Address;
             // just grab the first one we find
         } else {
             $email = Email::Load($facilitatorList[2]->PrimaryEmailId)->Address;
         }
         $strBody .= sprintf("<b>Option 3</b><br>%s, %s <br><b>Contact:</b> %s %s<br>%s<br>", $groupInfo[2][0], $groupInfo[2][1], $facilitatorList[2]->FirstName, $facilitatorList[2]->LastName, $email);
         $objMessage->Cc .= ', ' . $email;
     }
     $strBody .= '<br>* Please don\'t hesitate to visit a group for 2 to 3 times before prayerfully deciding if the ' . 'group is a good fit for you.<br><br>';
     $strBody .= 'Regards,<br/><b>Carisa Hamilton</b>';
     $objMessage->HtmlBody = $strBody;
     // Add random/custom email headers
     $objMessage->SetHeader('x-application', 'Growth Groups Ministry');
     QEmailServer::Send($objMessage);
 }
function sendFailureEmail($intPersonId, $intDonationId, $strCardholderName, $intCreditCardTypeId, $strAccountNumber, $strPaymentItems, $intAmount, $status)
{
    // Set debug mode
    //QEmailServer::$TestMode = true;
    //QEmailServer::$TestModeDirectory = __DOCROOT__ . '/../file_assets/emails';
    QEmailServer::$SmtpServer = SMTP_SERVER;
    $objPerson = Person::Load($intPersonId);
    $strEmail = $objPerson->GetEmailToUseForCommLists();
    // Create a new message
    // Note that you can list multiple addresses and that Qcodo supports Bcc and Cc
    $objMessage->From = 'ALCF Support <*****@*****.**>';
    $objMessage->To = $strEmail;
    $objMessage->Bcc = 'ALCF Support <*****@*****.**>';
    $objMessage->Subject = 'Notification of Recurring Payment Failure';
    // Setup Plaintext Message
    $strBody = '======= DO NOT REPLY =======\\r\\n';
    $strBody .= sprintf("Dear %s %s,\r\n\r\n", $objPerson->FirstName, $objPerson->LastName);
    $strBody .= 'r\\n';
    $strBody .= sprintf("Your (Recurring)online donation to Abundant Life Christian Fellowship.  Your transaction number is %d.  \r\n\r\n", $intDonationId);
    $strBody .= sprintf("An attempt to charge \$%01.2f on your credit card %s x%s failed.  The following is a summary of the attempted donation:\r\n", $intAmount, CreditCardType::ToString($intCreditCardTypeId), substr($strAccountNumber, strlen($strAccountNumber) - 4));
    for ($i = 0; $i < count($itemarray); $i++) {
        $strBody .= sprintf("%s\r\n", $itemarray[$i]);
    }
    $strBody .= sprintf("The failure was due to: %s\r\n", $status);
    $strBody .= "Please review your credit card details online at https://my.alcf.net, and verify that the details are correct.\r\n";
    $strBody .= "If you have any questions, please don't hesitate to call Oom Vang at 650-561-8026 or email Oom.Vang@alcf.net.\r\n";
    $strBody .= "Thank you for your continued support of the ministry at Abundant Life Christian Fellowship!\r\n\r\n";
    $strBody .= "============================<br>";
    $strBody .= "P.S. This email was sent from an unmanaged email account.  Please do not reply, as any replies to this message will bounce back.";
    $objMessage->Body = $strBody;
    // Also setup HTML message (optional)
    $strBody = '======= DO NOT REPLY =======';
    $strBody .= sprintf("Dear %s %s,<br><br>", $objPerson->FirstName, $objPerson->LastName);
    $strBody .= sprintf("Your (Recurring)online donation to Abundant Life Christian Fellowship.  Your transaction number is %d.  <br><br>", $intDonationId);
    $strBody .= sprintf("An attempt to charge %01.2f on your credit card %s x%s failed.  The following is a summary of the attempted donation:<br>", $intAmount, substr($strAccountNumber, CreditCardType::ToString($intCreditCardTypeId), strlen($strAccountNumber) - 4));
    for ($i = 0; $i < count($itemarray); $i++) {
        $strBody .= sprintf("%s<br>", $itemarray[$i]);
    }
    $strBody .= sprintf("The failure was due to: %s<br>", $status);
    $strBody .= "Please review your credit card details online at https://my.alcf.net, and verify that the details are correct.<br>";
    $strBody .= "If you have any questions, please don't hesitate to call Oom Vang at 650-561-8026 or email Oom.Vang@alcf.net.<br>";
    $strBody .= "Thank you for your continued support of the ministry at Abundant Life Christian Fellowship!<br><br>";
    $strBody .= "============================<br>";
    $strBody .= "P.S. This email was sent from an unmanaged email account.  Please do not reply, as any replies to this message will bounce back.";
    $objMessage->HtmlBody = $strBody;
    // Add random/custom email headers
    $objMessage->SetHeader('x-application', 'Recurring Online Donation');
    QEmailServer::Send($objMessage);
}
Example #21
0
<?php

QEmailServer::$SmtpServer = SMTP_SERVER;
QEmailServer::$SmtpPort = SMTP_PORT;
QEmailServer::$SmtpUsername = SMTP_USERNAME;
QEmailServer::$SmtpPassword = SMTP_PASSWORD;
QEmailServer::$AuthLogin = true;
$objEmailQueue = EmailQueue::QueryArray(QQ::IsNull(QQN::EmailQueue()->ErrorFlag), QQ::Clause(QQ::LimitInfo(50)));
foreach ($objEmailQueue as $objEmail) {
    $objEmail->Send();
}
if (defined('ERROR_LOG_PATH') && ERROR_LOG_PATH && defined('ERROR_LOG_FLAG') && ERROR_LOG_FLAG) {
    // Log to File in ERROR_LOG_PATH
    $strContents = ob_get_contents();
    QApplication::MakeDirectory(ERROR_LOG_PATH, 0777);
    $strFileName = ERROR_LOG_PATH . '/' . date('Y-m-d-H-i-s-' . rand(100, 999)) . '.html';
    file_put_contents($strFileName, $strContents);
    @chmod($strFileName, 0666);
}
if (defined('ERROR_EMAIL')) {
    $objEmail = new QEmailMessage();
    $objEmail->From = ERROR_EMAIL_FROM;
    $objEmail->Subject = ERROR_EMAIL_SUBJECT;
    $objEmail->To = ERROR_EMAIL;
    $strContents = ob_get_contents();
    $objEmail->HtmlBody = $strContents;
    QEmailServer::Send($objEmail);
}
if (QApplication::$RequestMode == QRequestMode::Ajax) {
    if (defined('ERROR_FRIENDLY_AJAX_MESSAGE') && ERROR_FRIENDLY_AJAX_MESSAGE) {
        // Reset the Buffer
        while (ob_get_level()) {
            ob_end_clean();
        }
        //$strAlertMsg = str_replace('"', '\\"', ERROR_FRIENDLY_AJAX_MESSAGE);
        $strMsg = str_replace('\\r\\n', '<br />', ERROR_FRIENDLY_AJAX_MESSAGE);
        echo '<p>' . $strMsg . '</p>';
    }
} else {
    if (defined('ERROR_FRIENDLY_PAGE_PATH') && ERROR_FRIENDLY_PAGE_PATH) {
        // Reset the Buffer
        while (ob_get_level()) {
Example #23
0
File: index.php Project: alcf/chms
 public function SendMessage($strSubscribedList)
 {
     // Set debug mode
     //QEmailServer::$TestMode = true;
     //QEmailServer::$TestModeDirectory = __DOCROOT__ . '/../file_assets/emails';
     QEmailServer::$SmtpServer = SMTP_SERVER;
     // Create a new message
     // Note that you can list multiple addresses and that Qcodo supports Bcc and Cc
     $objMessage = new QEmailMessage();
     $objMessage->From = 'info@alcf.net <*****@*****.**>';
     $objMessage->To = $this->txtEmail->Text;
     $objMessage->Subject = 'Subscription Confirmation';
     // Setup Plaintext Message
     $strBody = "Dear " . $this->txtFirstName->Text . ",\r\n\r\n";
     $strBody .= sprintf("You have been successfully subscribed to the %s email list.", $strSubscribedList);
     $strBody .= sprintf("\r\nIf you did not subscribe to the list, please contact info@alcf.net");
     $strBody .= '\\r\\nRegards, \\r\\nALCF Communications';
     $objMessage->Body = $strBody;
     // Also setup HTML message (optional)
     $strBody = "Dear " . $this->txtFirstName->Text . ',<br/><br/>';
     $strBody .= sprintf("You have been successfully subscribed to the %s email list.", $strSubscribedList);
     $strBody .= sprintf("<br>If you did not subscribe to the list, please contact info@alcf.net");
     $strBody .= '<br>Regards,<br/><b>ALCF Communications</b>';
     $objMessage->HtmlBody = $strBody;
     // Add random/custom email headers
     $objMessage->SetHeader('x-application', 'Communications Team');
     QEmailServer::Send($objMessage);
 }
<?php

QEmailServer::$SmtpServer = SMTP_SERVER;
QEmailServer::$OriginatingServerIp = SMTP_EHLO;
QEmailServer::$TestMode = SMTP_TEST_MODE;
$objEmailQueue = EmailQueue::QueryArray(QQ::IsNull(QQN::EmailQueue()->ErrorFlag), QQ::Clause(QQ::OrderBy(QQN::EmailQueue()->HighPriorityFlag, false), QQ::LimitInfo(50)));
foreach ($objEmailQueue as $objEmail) {
    $objEmail->Send();
}
Example #25
0
 /**
  * Sends a message out via SMTP according to the server, ip, etc. preferences
  * as set up on the class.  Takes in a QEmailMessage object.
  *
  * Will throw a QEmailException exception on any error.
  *
  * @param QEmailMessage $objMessage Message to Send
  * @return void
  */
 public static function Send(QEmailMessage $objMessage)
 {
     $objResource = null;
     if (QEmailServer::$TestMode) {
         // Open up a File Resource to the TestModeDirectory
         $strArray = split(' ', microtime());
         $strFileName = sprintf('%s/email_%s%s.txt', QEmailServer::$TestModeDirectory, $strArray[1], substr($strArray[0], 1));
         $objResource = fopen($strFileName, 'w');
         if (!$objResource) {
             throw new QEmailException(sprintf('Unable to open Test SMTP connection to: %s', $strFileName));
         }
         // Clear the Read Buffer
         if (!feof($objResource)) {
             fgets($objResource, 4096);
         }
         // Write the Connection Command
         fwrite($objResource, sprintf("telnet %s %s\r\n", QEmailServer::$SmtpServer, QEmailServer::$SmtpPort));
     } else {
         $objResource = fsockopen(QEmailServer::$SmtpServer, QEmailServer::$SmtpPort);
         if (!$objResource) {
             throw new QEmailException(sprintf('Unable to open SMTP connection to: %s %s', QEmailServer::$SmtpServer, QEmailServer::$SmtpPort));
         }
     }
     // Connect
     $strResponse = null;
     if (!feof($objResource)) {
         $strResponse = fgets($objResource, 4096);
         // Check for a "220" response
         if (strpos($strResponse, "220") === false || strpos($strResponse, "220") != 0) {
             throw new QEmailException(sprintf('Error Response on Connect: %s', $strResponse));
         }
     }
     // Send: EHLO
     fwrite($objResource, sprintf("EHLO %s\r\n", QEmailServer::$OriginatingServerIp));
     if (!feof($objResource)) {
         $strResponse = fgets($objResource, 4096);
         // Iterate through all "250-" responses (stop at "250 ")
         while (substr($strResponse, 0, 3) == "250" && substr($strResponse, 0, 4) != "250 ") {
             if (!feof($objResource)) {
                 $strResponse = fgets($objResource, 4096);
             }
         }
         // Check for a "250" response
         if (strpos($strResponse, "250") === false || strpos($strResponse, "250") != 0) {
             throw new QEmailException(sprintf('Error Response on EHLO: %s', $strResponse));
         }
     }
     // Send Authentication
     if (QEmailServer::$AuthPlain) {
         fwrite($objResource, "AUTH PLAIN " . base64_encode(QEmailServer::$SmtpUsername . "" . QEmailServer::$SmtpUsername . "" . QEmailServer::$SmtpPassword) . "\r\n");
         if (!feof($objResource)) {
             $strResponse = fgets($objResource, 4096);
         }
         if (strpos($strResponse, "235") === false || strpos($strResponse, "235") != 0) {
             throw new QEmailException(sprintf('Error in response from AUTH PLAIN: %s', $strResponse));
         }
     }
     if (QEmailServer::$AuthLogin) {
         fwrite($objResource, "AUTH LOGIN\r\n");
         if (!feof($objResource)) {
             $strResponse = fgets($objResource, 4096);
         }
         if (strpos($strResponse, "334") === false || strpos($strResponse, "334") != 0) {
             throw new QEmailException(sprintf('Error in response from AUTH LOGIN: %s', $strResponse));
         }
         fwrite($objResource, base64_encode(QEmailServer::$SmtpUsername) . "\r\n");
         if (!feof($objResource)) {
             $strResponse = fgets($objResource, 4096);
         }
         if (strpos($strResponse, "334") === false || strpos($strResponse, "334") != 0) {
             throw new QEmailException(sprintf('Error in response from AUTH LOGIN: %s', $strResponse));
         }
         fwrite($objResource, base64_encode(QEmailServer::$SmtpPassword) . "\r\n");
         if (!feof($objResource)) {
             $strResponse = fgets($objResource, 4096);
         }
         if (strpos($strResponse, "235") === false || strpos($strResponse, "235") != 0) {
             throw new QEmailException(sprintf('Error in response from AUTH LOGIN: %s', $strResponse));
         }
     }
     // Setup MAIL FROM line
     $strAddressArray = QEmailServer::GetEmailAddresses($objMessage->From);
     if (count($strAddressArray) != 1) {
         throw new QEmailException(sprintf('Not a valid From address: %s', $objMessage->From));
     }
     // Send: MAIL FROM line
     fwrite($objResource, sprintf("MAIL FROM: %s\r\n", $strAddressArray[0]));
     if (!feof($objResource)) {
         $strResponse = fgets($objResource, 4096);
         // Check for a "250" response
         if (strpos($strResponse, "250") === false || strpos($strResponse, "250") != 0) {
             throw new QEmailException(sprintf('Error Response on MAIL FROM: %s', $strResponse));
         }
     }
     // Setup RCPT TO line(s)
     $strAddressToArray = QEmailServer::GetEmailAddresses($objMessage->To);
     if (!$strAddressToArray) {
         throw new QEmailException(sprintf('Not a valid To address: %s', $objMessage->To));
     }
     $strAddressCcArray = QEmailServer::GetEmailAddresses($objMessage->Cc);
     if (!$strAddressCcArray) {
         $strAddressCcArray = array();
     }
     $strAddressBccArray = QEmailServer::GetEmailAddresses($objMessage->Bcc);
     if (!$strAddressBccArray) {
         $strAddressBccArray = array();
     }
     $strAddressCcBccArray = array_merge($strAddressCcArray, $strAddressBccArray);
     $strAddressArray = array_merge($strAddressToArray, $strAddressCcBccArray);
     // Send: RCPT TO line(s)
     foreach ($strAddressArray as $strAddress) {
         fwrite($objResource, sprintf("RCPT TO: %s\r\n", $strAddress));
         if (!feof($objResource)) {
             $strResponse = fgets($objResource, 4096);
             // Check for a "250" response
             if (strpos($strResponse, "250") === false || strpos($strResponse, "250") != 0) {
                 throw new QEmailException(sprintf('Error Response on RCPT TO: %s', $strResponse));
             }
         }
     }
     // Send: DATA
     fwrite($objResource, "DATA\r\n");
     if (!feof($objResource)) {
         $strResponse = fgets($objResource, 4096);
         // Check for a "354" response
         if (strpos($strResponse, "354") === false || strpos($strResponse, "354") != 0) {
             throw new QEmailException(sprintf('Error Response on DATA: %s', $strResponse));
         }
     }
     // Send: Required Headers
     fwrite($objResource, sprintf("Date: %s\r\n", QDateTime::NowToString(QDateTime::FormatRfc822)));
     fwrite($objResource, sprintf("To: %s\r\n", $objMessage->To));
     fwrite($objResource, sprintf("From: %s\r\n", $objMessage->From));
     // Send: Optional Headers
     if ($objMessage->Subject) {
         fwrite($objResource, sprintf("Subject: %s\r\n", $objMessage->Subject));
     }
     if ($objMessage->Cc) {
         fwrite($objResource, sprintf("Cc: %s\r\n", $objMessage->Cc));
     }
     // Send: Content-Type Header (if applicable)
     $strBoundary = 'qcodo_qemailserver_multipart_boundary____';
     if ($objMessage->HtmlBody) {
         fwrite($objResource, sprintf("Content-Type: multipart/alternative; boundary=\"%s\"\r\n", $strBoundary));
     }
     // Send: Other Headers (if any)
     foreach ($objArray = $objMessage->HeaderArray as $strKey => $strValue) {
         fwrite($objResource, sprintf("%s: %s\r\n", $strKey, $strValue));
     }
     // Send: Body
     fwrite($objResource, "\r\n");
     if ($objMessage->HtmlBody) {
         fwrite($objResource, sprintf("--%s\r\n", $strBoundary));
         fwrite($objResource, sprintf("Content-Type: text/plain; charset=%s\r\n\r\n", QApplication::$EncodingType));
         fwrite($objResource, $objMessage->Body);
         fwrite($objResource, "\r\n\r\n\r\n");
         fwrite($objResource, sprintf("--%s\r\n", $strBoundary));
         fwrite($objResource, sprintf("Content-Type: text/html; charset=%s\r\n\r\n", QApplication::$EncodingType));
         fwrite($objResource, $objMessage->HtmlBody);
         fwrite($objResource, "\r\n\r\n\r\n");
         fwrite($objResource, sprintf("--%s--\r\n", $strBoundary));
     } else {
         fwrite($objResource, $objMessage->Body);
     }
     // Send: Message End
     fwrite($objResource, "\r\n.\r\n");
     if (!feof($objResource)) {
         $strResponse = fgets($objResource, 4096);
         // Check for a "250" response
         if (strpos($strResponse, "250") === false || strpos($strResponse, "250") != 0) {
             throw new QEmailException(sprintf('Error Response on MAIL FROM: %s', $strResponse));
         }
     }
     // Send: QUIT
     fwrite($objResource, "QUIT\r\n");
     if (!feof($objResource)) {
         $strResponse = fgets($objResource, 4096);
     }
     // Close the Resource
     fclose($objResource);
 }