当前位置: 首页>>代码示例>>PHP>>正文


PHP EmailMessage::validate方法代码示例

本文整理汇总了PHP中EmailMessage::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP EmailMessage::validate方法的具体用法?PHP EmailMessage::validate怎么用?PHP EmailMessage::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EmailMessage的用法示例。


在下文中一共展示了EmailMessage::validate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sendSystemEmail

 /**
  * Send system email message
  * @param string $subject
  * @param array $recipients
  * @param string $textContent
  * @param string $htmlContent
  * @throws NotSupportedException
  */
 public static function sendSystemEmail($subject, $recipients, $textContent = '', $htmlContent = '')
 {
     $emailMessage = new EmailMessage();
     $emailMessage->owner = BaseControlUserConfigUtil::getUserToRunAs();
     $emailMessage->subject = $subject;
     $emailContent = new EmailMessageContent();
     $emailContent->textContent = $textContent;
     $emailContent->htmlContent = $htmlContent;
     $emailMessage->content = $emailContent;
     $sender = new EmailMessageSender();
     $sender->fromAddress = Yii::app()->emailHelper->resolveFromAddressByUser(Yii::app()->user->userModel);
     $sender->fromName = strval(Yii::app()->user->userModel);
     $sender->personsOrAccounts->add(Yii::app()->user->userModel);
     $emailMessage->sender = $sender;
     foreach ($recipients as $recipientEmail) {
         $recipient = new EmailMessageRecipient();
         $recipient->toAddress = $recipientEmail;
         $recipient->type = EmailMessageRecipient::TYPE_TO;
         $emailMessage->recipients->add($recipient);
     }
     $box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
     $emailMessage->folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_DRAFT);
     $validated = $emailMessage->validate();
     if (!$validated) {
         throw new NotSupportedException();
     }
     Yii::app()->emailHelper->sendImmediately($emailMessage);
     $saved = $emailMessage->save();
     if (!$saved) {
         throw new NotSupportedException();
     }
     if (!$emailMessage->hasSendError()) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:45,代码来源:EmailMessageHelper.php

示例2: sendTestEmail

 /**
  * Send a test email.
  * $from('name' => 'fromName', 'address' => 'fromAddress')
  * @param EmailHelper $emailHelper
  * @param Array $from
  * @param string $toAddress
  */
 public static function sendTestEmail(EmailHelper $emailHelper, array $from, $toAddress)
 {
     assert('is_string($from["name"])');
     assert('is_string($from["address"])');
     $emailMessage = new EmailMessage();
     $emailMessage->owner = Yii::app()->user->userModel;
     $emailMessage->subject = Zurmo::t('EmailMessagesModule', 'A test email from Zurmo', LabelUtil::getTranslationParamsForAllModules());
     $emailContent = new EmailMessageContent();
     $emailContent->textContent = EmailNotificationUtil::resolveNotificationTextTemplate(Zurmo::t('EmailMessagesModule', 'A test text message from Zurmo.', LabelUtil::getTranslationParamsForAllModules()));
     $emailContent->htmlContent = EmailNotificationUtil::resolveNotificationHtmlTemplate(Zurmo::t('EmailMessagesModule', 'A test text message from Zurmo.', LabelUtil::getTranslationParamsForAllModules()));
     $emailMessage->content = $emailContent;
     $sender = new EmailMessageSender();
     $sender->fromAddress = $from['address'];
     $sender->fromName = $from['name'];
     $emailMessage->sender = $sender;
     $recipient = new EmailMessageRecipient();
     $recipient->toAddress = $toAddress;
     $recipient->toName = 'Test Recipient';
     $recipient->type = EmailMessageRecipient::TYPE_TO;
     $emailMessage->recipients->add($recipient);
     $box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
     $emailMessage->folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_DRAFT);
     $validated = $emailMessage->validate();
     if ($validated) {
         $emailHelper->sendImmediately($emailMessage);
     }
     return $emailMessage;
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:35,代码来源:EmailMessageHelper.php

示例3: actionSend

 /**
  * Execute the action.
  * @param array command line parameters specific for this command
  */
 public function actionSend($username, $toAddress, $subject = 'A test email from Zurmo', $textContent = 'A test text message from Zurmo.', $htmlContent = 'A test html message from Zurmo.', $host = null, $port = null, $outboundUsername = null, $outboundPassword = null, $outboundSecurity = null)
 {
     if (!isset($username)) {
         $this->usageError('A username must be specified.');
     }
     if (!isset($toAddress)) {
         $this->usageError('You must specify a to address.');
     }
     try {
         Yii::app()->user->userModel = User::getByUsername($username);
     } catch (NotFoundException $e) {
         $this->usageError('The specified username does not exist.');
     }
     if ($host != null) {
         Yii::app()->emailHelper->outboundHost = $host;
     }
     if ($port != null) {
         Yii::app()->emailHelper->outboundPort = $port;
     }
     if ($outboundUsername != null) {
         Yii::app()->emailHelper->outboundUsername = $outboundUsername;
     }
     if ($outboundUsername != null) {
         Yii::app()->emailHelper->outboundPassword = $outboundPassword;
     }
     if ($outboundSecurity != null && $outboundSecurity != '' && $outboundSecurity != 'false') {
         Yii::app()->emailHelper->outboundSecurity = $outboundSecurity;
     } else {
         Yii::app()->emailHelper->outboundSecurity = null;
     }
     echo "\n";
     echo 'Using type:' . Yii::app()->emailHelper->outboundType . "\n";
     echo 'Using host:' . Yii::app()->emailHelper->outboundHost . "\n";
     echo 'Using port:' . Yii::app()->emailHelper->outboundPort . "\n";
     echo 'Using username:' . Yii::app()->emailHelper->outboundUsername . "\n";
     echo 'Using password:' . Yii::app()->emailHelper->outboundPassword . "\n";
     if (isset(Yii::app()->emailHelper->outboundSecurity)) {
         echo 'Using outbound security:' . Yii::app()->emailHelper->outboundSecurity . "\n\n";
     } else {
         echo 'Using outbound security: none' . "\n\n";
     }
     echo 'Sending Email Message' . "\n";
     $emailMessage = new EmailMessage();
     $emailMessage->owner = BaseJobControlUserConfigUtil::getUserToRunAs();
     $emailMessage->subject = $subject;
     $emailContent = new EmailMessageContent();
     $emailContent->textContent = $textContent;
     $emailContent->htmlContent = $htmlContent;
     $emailMessage->content = $emailContent;
     $sender = new EmailMessageSender();
     $sender->fromAddress = Yii::app()->emailHelper->resolveFromAddressByUser(Yii::app()->user->userModel);
     $sender->fromName = strval(Yii::app()->user->userModel);
     $sender->personOrAccount = Yii::app()->user->userModel;
     $emailMessage->sender = $sender;
     $recipient = new EmailMessageRecipient();
     $recipient->toAddress = $toAddress;
     $recipient->toName = 'Test Recipient';
     $recipient->type = EmailMessageRecipient::TYPE_TO;
     $emailMessage->recipients->add($recipient);
     $box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
     $emailMessage->folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_DRAFT);
     $validated = $emailMessage->validate();
     if (!$validated) {
         $this->addErrorsAsUsageErrors($emailMessage->getErrors());
     }
     Yii::app()->emailHelper->sendImmediately($emailMessage);
     if (!$emailMessage->hasSendError()) {
         echo Zurmo::t('Commands', 'Message successfully sent') . "\n";
     } else {
         echo Zurmo::t('Commands', 'Message failed to send') . "\n";
         echo $emailMessage->error . "\n";
     }
     $saved = $emailMessage->save();
     if (!$saved) {
         throw new NotSupportedException();
     }
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:81,代码来源:EmailCommand.php

示例4: run

 /**
  *
  * (non-PHPdoc)
  * @see BaseJob::run()
  */
 public function run()
 {
     $messageContent = null;
     $userToSendMessagesFrom = BaseControlUserConfigUtil::getUserToRunAs();
     $emailMessage = new EmailMessage();
     $emailMessage->owner = Yii::app()->user->userModel;
     $emailMessage->subject = Zurmo::t('EmailMessagesModule', 'A test email from Zurmo', LabelUtil::getTranslationParamsForAllModules());
     $emailContent = new EmailMessageContent();
     $emailContent->textContent = Zurmo::t('EmailMessagesModule', 'A test text message from Zurmo.', LabelUtil::getTranslationParamsForAllModules());
     $emailContent->htmlContent = Zurmo::t('EmailMessagesModule', 'A test text message from Zurmo.', LabelUtil::getTranslationParamsForAllModules());
     $emailMessage->content = $emailContent;
     $sender = new EmailMessageSender();
     $sender->fromAddress = Yii::app()->emailHelper->resolveFromAddressByUser($userToSendMessagesFrom);
     $sender->fromName = strval($userToSendMessagesFrom);
     $emailMessage->sender = $sender;
     $recipient = new EmailMessageRecipient();
     $recipient->toAddress = Yii::app()->emailHelper->defaultTestToAddress;
     $recipient->toName = 'Test Recipient';
     $recipient->type = EmailMessageRecipient::TYPE_TO;
     $emailMessage->recipients->add($recipient);
     $box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
     $emailMessage->folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_DRAFT);
     $validated = $emailMessage->validate();
     if (!$validated) {
         throw new NotSupportedException();
     }
     Yii::app()->emailHelper->sendImmediately($emailMessage);
     if (!$emailMessage->hasSendError()) {
         $messageContent .= Zurmo::t('EmailMessagesModule', 'Message successfully sent') . "\n";
         return true;
     } else {
         $messageContent .= Zurmo::t('EmailMessagesModule', 'Message failed to send') . "\n";
         $messageContent .= $emailMessage->error . "\n";
         $this->errorMessage = $messageContent;
         return false;
     }
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:42,代码来源:TestOutboundEmailJob.php

示例5: saveEmailMessage

 /**
  * Save email message
  * This method should be protected, but we made it public for unit testing, so don't call it outside this class.
  * @param ImapMessage $message
  * @throws NotSupportedException
  * @return boolean
  */
 public function saveEmailMessage(ImapMessage $message)
 {
     // Get owner for message
     try {
         $emailOwner = EmailArchivingUtil::resolveOwnerOfEmailMessage($message);
     } catch (CException $e) {
         // User not found, so inform user about issue and continue with next email.
         $this->resolveMessageSubjectAndContentAndSendSystemMessage('OwnerNotExist', $message);
         return false;
     }
     $emailSenderOrRecipientEmailFoundInSystem = false;
     $userCanAccessContacts = RightsUtil::canUserAccessModule('ContactsModule', $emailOwner);
     $userCanAccessLeads = RightsUtil::canUserAccessModule('LeadsModule', $emailOwner);
     $userCanAccessAccounts = RightsUtil::canUserAccessModule('AccountsModule', $emailOwner);
     $senderInfo = EmailArchivingUtil::resolveEmailSenderFromEmailMessage($message);
     if (!$senderInfo) {
         $this->resolveMessageSubjectAndContentAndSendSystemMessage('SenderNotExtracted', $message);
         return false;
     } else {
         $sender = EmailArchivingUtil::createEmailMessageSender($senderInfo, $userCanAccessContacts, $userCanAccessLeads, $userCanAccessAccounts);
         if ($sender->personsOrAccounts->count() > 0) {
             $emailSenderOrRecipientEmailFoundInSystem = true;
         }
     }
     try {
         $recipientsInfo = EmailArchivingUtil::resolveEmailRecipientsFromEmailMessage($message);
     } catch (NotSupportedException $exception) {
         $this->resolveMessageSubjectAndContentAndSendSystemMessage('RecipientNotExtracted', $message);
         return false;
     }
     $emailMessage = new EmailMessage();
     $emailMessage->owner = $emailOwner;
     $emailMessage->subject = $message->subject;
     $emailContent = new EmailMessageContent();
     $emailContent->textContent = $message->textBody;
     $emailContent->htmlContent = $message->htmlBody;
     $emailMessage->content = $emailContent;
     $emailMessage->sender = $sender;
     $emailRecipientFoundInSystem = false;
     foreach ($recipientsInfo as $recipientInfo) {
         $recipient = EmailArchivingUtil::createEmailMessageRecipient($recipientInfo, $userCanAccessContacts, $userCanAccessLeads, $userCanAccessAccounts);
         $emailMessage->recipients->add($recipient);
         // Check if at least one recipient email can't be found in Contacts, Leads, Account and User emails
         // so we will save email message in EmailFolder::TYPE_ARCHIVED_UNMATCHED folder, and user will
         // be able to match emails with items(Contacts, Accounts...) emails in systems
         if ($recipient->personsOrAccounts->count() > 0) {
             $emailRecipientFoundInSystem = true;
         }
     }
     // Override $emailSenderOrRecipientEmailFoundInSystem only if there are no errors
     if ($emailSenderOrRecipientEmailFoundInSystem == true) {
         $emailSenderOrRecipientEmailFoundInSystem = $emailRecipientFoundInSystem;
     }
     if ($emailOwner instanceof User) {
         $box = EmailBoxUtil::getDefaultEmailBoxByUser($emailOwner);
     } else {
         $box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
     }
     if (!$emailSenderOrRecipientEmailFoundInSystem) {
         $emailMessage->folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_ARCHIVED_UNMATCHED);
         $notificationMessage = new NotificationMessage();
         $notificationMessage->textContent = Zurmo::t('EmailMessagesModule', 'At least one archived email message does ' . 'not match any records in the system. ' . 'To manually match them use this link: {url}.', array('{url}' => Yii::app()->createUrl('emailMessages/default/matchingList')));
         $notificationMessage->htmlContent = Zurmo::t('EmailMessagesModule', 'At least one archived email message does ' . 'not match any records in the system. ' . '<a href="{url}" target="_blank">Click here</a> to manually match them.', array('{url}' => Yii::app()->createUrl('emailMessages/default/matchingList')));
         if ($emailOwner instanceof User) {
             $rules = new EmailMessageArchivingEmailAddressNotMatchingNotificationRules();
             $rules->addUser($emailOwner);
             NotificationsUtil::submit($notificationMessage, $rules);
         }
     } else {
         $emailMessage->folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_ARCHIVED);
     }
     if (!empty($message->attachments)) {
         foreach ($message->attachments as $attachment) {
             if (!$attachment['is_attachment']) {
                 continue;
             }
             $file = EmailArchivingUtil::createEmailAttachment($attachment);
             if ($file instanceof FileModel) {
                 $emailMessage->files->add($file);
             }
         }
     }
     $emailMessage->sentDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
     $validated = $emailMessage->validate();
     if (!$validated) {
         // Email message couldn't be validated(some related models can't be validated). Email user.
         $this->resolveMessageSubjectAndContentAndSendSystemMessage('EmailMessageNotValidated', $message);
         return false;
     }
     EmailArchivingUtil::resolveSanitizeFromImapToUtf8($emailMessage);
     $saved = $emailMessage->save();
     try {
         if (!$saved) {
//.........这里部分代码省略.........
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:101,代码来源:EmailArchivingJob.php


注:本文中的EmailMessage::validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。