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; }
public function testInIsEmailValidTest_UnpartneredSquareBracketIp() { $this->assertFalse(QEmailServer::IsEmailValid('test@[123.123.123.123')); $this->assertFalse(QEmailServer::IsEmailValid('test@123.123.123.123]')); }
/** * This will send this message in PendingSend status, given a limit of how many to send out. * It will first attempt to send bounces... then it will send actuals (up to the limit) * per token. * * If all OutgoingMessageQueus are exhuasted for this EmailMessage, then this EmailMessage * status will be set to Completed, CompletedWithSomeRejections or Rejected * @return void */ public function SendMessage($intMaxPerEmail) { // First process errors $objToSend = EmailOutgoingQueue::LoadArrayByEmailMessageIdErrorFlag($this->intId, true); foreach ($objToSend as $objEmailOutgoingQueue) { $objSmtpMessage = new QEmailMessage(GROUPS_SERVER_BOUNCE_EMAIL, $objEmailOutgoingQueue->ToAddress, GROUPS_SERVER_BOUNCE_SUBJECT, $this->ErrorMessage . "\r\n\r\n----- Original message -----\r\n\r\n" . $this->strRawMessage); QEmailServer::Send($objSmtpMessage); $objEmailOutgoingQueue->Delete(); } // Second process successes $this->GetHeaderArray(); $this->ClearHeaderValue('Subject'); $this->ClearHeaderValue('Message-Id'); $this->ClearHeaderValue('Message-ID'); $this->ClearHeaderValue('Message-id'); $this->ClearHeaderValue('message-id'); $this->ClearHeaderValue('MESSAGE-ID'); foreach ($this->GetEmailMessageRouteArray() as $objRoute) { $objToSend = EmailOutgoingQueue::LoadArrayByEmailMessageIdToken($this->Id, $objRoute->Token, QQ::LimitInfo($intMaxPerEmail)); if (count($objToSend)) { $strHeaderArray = $this->strHeaderArray; $strSubject = $this->Subject; if (strpos(strtolower($strSubject), '[' . trim(strtolower($objRoute->Name)) . ']') === false) { $strSubject = '[' . trim($objRoute->Name) . '] ' . $strSubject; } $strHeaderArray['Subject'] = $strSubject; //GJS - add a Reply-To in the header $strHeaderArray['Reply-To'] = $this->FromAddress; $strRcptToArray = array(); foreach ($objToSend as $objEmailOutgoingQueue) { if (QEmailServer::IsEmailValid($objEmailOutgoingQueue->ToAddress)) { $strRcptToArray[] = $objEmailOutgoingQueue->ToAddress; } } // GJS - Ensure that From address is the email of the group instead. This is to get around new email policies. // $this->FromAddress $txtFromAddress = "{$this->FromAddress}"; // default if we can't extract the group name; if ($this->_EmailMessageRoute) { if ($this->_EmailMessageRoute->CommunicationList) { $txtFromAddress = $this->_EmailMessageRoute->CommunicationList->Token . 'groups.alcf.net'; } else { if ($this->_EmailMessageRoute->Group->Token) { $txtFromAddress = $this->_EmailMessageRoute->Group->Token . 'groups.alcf.net'; } } } QEmailServer::SendRawMessage($txtFromAddress, $strRcptToArray, $strHeaderArray, $this->ResponseBody); foreach ($objToSend as $objEmailOutgoingQueue) { $objEmailOutgoingQueue->Delete(); } } } // Finally, update status (if applicable) if (!$this->CountEmailOutgoingQueues()) { if ($this->CountEmailMessageRoutes() && $this->ErrorMessage) { $this->intEmailMessageStatusTypeId = EmailMessageStatusType::CompletedWithSomeRejections; } else { if ($this->CountEmailMessageRoutes()) { $this->intEmailMessageStatusTypeId = EmailMessageStatusType::Completed; } else { $this->intEmailMessageStatusTypeId = EmailMessageStatusType::Rejected; } } $this->Save(); } }
<?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); } }