本文整理汇总了PHP中EmailBox类的典型用法代码示例。如果您正苦于以下问题:PHP EmailBox类的具体用法?PHP EmailBox怎么用?PHP EmailBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EmailBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resolveEmailMessageFromPostData
/**
* Given post data and an email message, populate the sender and account on the email message if possible.
* Also add message recipients and any attachments.
* @param array $postData
* @param EmailMessage $emailMessage
* @param User $userToSendMessagesFrom
* @return boolean
*/
public static function resolveEmailMessageFromPostData(array &$postData, CreateEmailMessageForm $emailMessageForm, User $userToSendMessagesFrom)
{
$postVariableName = get_class($emailMessageForm);
Yii::app()->emailHelper->loadOutboundSettingsFromUserEmailAccount($userToSendMessagesFrom);
$toRecipients = explode(",", $postData[$postVariableName]['recipientsData']['to']);
// Not Coding Standard
static::attachRecipientsToMessage($toRecipients, $emailMessageForm->getModel(), EmailMessageRecipient::TYPE_TO);
if (ArrayUtil::getArrayValue($postData[$postVariableName]['recipientsData'], 'cc') != null) {
$ccRecipients = explode(",", $postData[$postVariableName]['recipientsData']['cc']);
// Not Coding Standard
static::attachRecipientsToMessage($ccRecipients, $emailMessageForm->getModel(), EmailMessageRecipient::TYPE_CC);
}
if (ArrayUtil::getArrayValue($postData[$postVariableName]['recipientsData'], 'bcc') != null) {
$bccRecipients = explode(",", $postData[$postVariableName]['recipientsData']['bcc']);
// Not Coding Standard
static::attachRecipientsToMessage($bccRecipients, $emailMessageForm->getModel(), EmailMessageRecipient::TYPE_BCC);
}
if (isset($postData['filesIds'])) {
static::attachFilesToMessage($postData['filesIds'], $emailMessageForm->getModel());
}
$emailAccount = EmailAccount::getByUserAndName($userToSendMessagesFrom);
$sender = new EmailMessageSender();
$sender->fromName = Yii::app()->emailHelper->fromName;
$sender->fromAddress = Yii::app()->emailHelper->fromAddress;
$sender->personOrAccount = $userToSendMessagesFrom;
$emailMessageForm->sender = $sender;
$emailMessageForm->account = $emailAccount;
$emailMessageForm->content->textContent = EmailMessageUtil::resolveTextContent(ArrayUtil::getArrayValue($postData[$postVariableName]['content'], 'htmlContent'), null);
$box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
$emailMessageForm->folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_OUTBOX);
return $emailMessageForm;
}
示例2: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
SecurityTestHelper::createSuperAdmin();
self::$emailHelperSendEmailThroughTransport = Yii::app()->emailHelper->sendEmailThroughTransport;
static::$userpsg = UserTestHelper::createBasicUser('userpsg');
static::$usercstmsmtp = UserTestHelper::createBasicUser('usercstmsmtp');
static::$basicuser = UserTestHelper::createBasicUser('basicuser');
static::$bothSGandCstmUser = UserTestHelper::createBasicUser('bothSGandCstmUser');
$someoneSuper = UserTestHelper::createBasicUser('someoneSuper');
$group = Group::getByName('Super Administrators');
$group->users->add($someoneSuper);
$saved = $group->save();
assert($saved);
// Not Coding Standard
$box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
if (EmailMessageTestHelper::isSetEmailAccountsTestConfiguration()) {
EmailMessageTestHelper::createEmailAccountForMailerFactory(static::$usercstmsmtp);
EmailMessageTestHelper::createEmailAccountForMailerFactory(static::$bothSGandCstmUser);
}
SendGrid::register_autoloader();
Smtpapi::register_autoloader();
if (SendGridTestHelper::isSetSendGridAccountTestConfiguration()) {
SendGridTestHelper::createSendGridEmailAccount(static::$userpsg);
SendGridTestHelper::createSendGridEmailAccount(static::$bothSGandCstmUser);
Yii::app()->sendGridEmailHelper->apiUsername = Yii::app()->params['emailTestAccounts']['sendGridGlobalSettings']['apiUsername'];
Yii::app()->sendGridEmailHelper->apiPassword = Yii::app()->params['emailTestAccounts']['sendGridGlobalSettings']['apiPassword'];
Yii::app()->sendGridEmailHelper->setApiSettings();
Yii::app()->sendGridEmailHelper->init();
}
// Delete item from jobQueue, that is created when new user is created
Yii::app()->jobQueue->deleteAll();
}
示例3: createDraftSendGridSystemEmail
public static function createDraftSendGridSystemEmail($subject, User $owner)
{
$emailMessage = new EmailMessage();
$emailMessage->owner = $owner;
$emailMessage->subject = $subject;
//Set sender, and recipient, and content
$emailContent = new EmailMessageContent();
$emailContent->textContent = 'My First Message';
$emailContent->htmlContent = 'Some fake HTML content';
$emailMessage->content = $emailContent;
//Sending from the system, does not have a 'person'.
$sender = new EmailMessageSender();
$sender->fromAddress = 'system@somewhere.com';
$sender->fromName = 'Zurmo System';
$emailMessage->sender = $sender;
//Recipient is billy.
$recipient = new EmailMessageRecipient();
$recipient->toAddress = 'billy@fakeemail.com';
$recipient->toName = 'Billy James';
$recipient->type = EmailMessageRecipient::TYPE_TO;
$emailMessage->recipients->add($recipient);
$box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
$emailMessage->folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_DRAFT);
//Save, at this point the email should be in the draft folder
$saved = $emailMessage->save();
if (!$saved) {
throw new NotSupportedException();
}
return $emailMessage;
}
示例4: testRun
public function testRun()
{
$quote = DatabaseCompatibilityUtil::getQuote();
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
$folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_SENT);
//Create 2 sent notifications, and set one with a date over a week ago (8 days ago) for the modifiedDateTime
$emailMessage = EmailMessageTestHelper::createDraftSystemEmail('My Email Message', $super);
$emailMessage->folder = $folder;
$saved = $emailMessage->save();
$this->assertTrue($saved);
$modifiedDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 60 * 60 * 24 * 8);
$sql = "Update item set modifieddatetime = '" . $modifiedDateTime . "' where id = " . $emailMessage->getClassId('Item');
ZurmoRedBean::exec($sql);
$emailMessage2 = EmailMessageTestHelper::createDraftSystemEmail('My Email Message 2', $super);
$emailMessage2->folder = $folder;
$saved = $emailMessage2->save();
$this->assertTrue($saved);
$this->assertEquals(2, EmailMessage::getCount());
$job = new ClearSentNotificationsEmailJob();
$this->assertTrue($job->run());
$emailMessages = EmailMessage::getAll();
$this->assertEquals(1, count($emailMessages));
$this->assertEquals($emailMessage2->id, $emailMessages[0]->id);
}
示例5: testRun
public function testRun()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
$outboxFolder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_OUTBOX);
$sentFolder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_SENT);
$emailMessage = EmailMessageTestHelper::createDraftSystemEmail('My Email Message', $super);
$emailMessage->folder = $outboxFolder;
$saved = $emailMessage->save();
$this->assertTrue($saved);
$emailMessageId = $emailMessage->id;
$emailMessage->forget();
unset($emailMessage);
$emailMessage2 = EmailMessageTestHelper::createDraftSystemEmail('My Email Message', $super);
$emailMessage2->folder = $outboxFolder;
$saved = $emailMessage2->save();
$this->assertTrue($saved);
$emailMessage2Id = $emailMessage2->id;
$emailMessage2->forget();
unset($emailMessage2);
$this->assertEquals(2, EmailMessage::getCount());
$job = new ProcessOutboundEmailJob();
$this->assertTrue($job->run());
$emailMessages = EmailMessage::getAll();
$this->assertEquals(2, count($emailMessages));
$emailMessage = EmailMessage::getById($emailMessageId);
$this->assertEquals($sentFolder, $emailMessage->folder);
$emailMessage2 = EmailMessage::getById($emailMessage2Id);
$this->assertEquals($sentFolder, $emailMessage2->folder);
}
示例6: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
SecurityTestHelper::createSuperAdmin();
AllPermissionsOptimizationUtil::rebuild();
$box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
}
示例7: testRenderSummaryContentWithEmailMessage
/**
* Testing that each model type can render properly and does not throw an exception
*/
public function testRenderSummaryContentWithEmailMessage()
{
$super = User::getByUsername('super');
$billy = User::getByUsername('billy');
$this->assertEquals(0, EmailMessage::getCount());
$emailMessage = new EmailMessage();
$emailMessage->owner = BaseControlUserConfigUtil::getUserToRunAs();
$emailMessage->subject = 'My First Email';
//Set sender, and recipient, and content
$emailContent = new EmailMessageContent();
$emailContent->textContent = 'My First Message';
$emailContent->htmlContent = 'Some fake HTML content';
$emailMessage->content = $emailContent;
//Sending from the system, does not have a 'person'.
$sender = new EmailMessageSender();
$sender->fromAddress = 'system@somewhere.com';
$sender->fromName = 'Zurmo System';
$sender->personsOrAccounts->add($super);
$emailMessage->sender = $sender;
//Recipient is billy.
$recipient = new EmailMessageRecipient();
$recipient->toAddress = 'billy@fakeemail.com';
$recipient->toName = 'Billy James';
$recipient->type = EmailMessageRecipient::TYPE_TO;
$recipient->personsOrAccounts->add($billy);
$emailMessage->recipients->add($recipient);
$box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
$emailMessage->folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_DRAFT);
$saved = $emailMessage->save();
$this->assertTrue($saved);
$content = ActivitiesUtil::renderSummaryContent($emailMessage, 'someUrl', LatestActivitiesConfigurationForm::OWNED_BY_FILTER_ALL, 'HomeModule');
$content = ActivitiesUtil::renderSummaryContent($emailMessage, 'someUrl', LatestActivitiesConfigurationForm::OWNED_BY_FILTER_USER, 'HomeModule');
$content = ActivitiesUtil::renderSummaryContent($emailMessage, 'someUrl', LatestActivitiesConfigurationForm::OWNED_BY_FILTER_ALL, 'UserModule');
$content = ActivitiesUtil::renderSummaryContent($emailMessage, 'someUrl', LatestActivitiesConfigurationForm::OWNED_BY_FILTER_USER, 'UserModule');
}
示例8: actionCategory
public function actionCategory()
{
$uid = Yii::app()->user->uid;
$myFolders = EmailBox::model()->fetchAllNotSysByUid($uid);
$notReadCount = Email::model()->countNotReadByToid($uid, "inbox");
$return = array("folders" => $myFolders, "notread" => $notReadCount);
$this->ajaxReturn($return, "JSONP");
}
示例9: getCategory
public function getCategory()
{
$gUid = Ibos::app()->user->uid;
$myFolders = EmailBox::model()->fetchAllNotSysByUid($gUid);
$notReadCount = Email::model()->countNotReadByToid($gUid, "inbox");
$return = array("folders" => $myFolders, "notread" => $notReadCount);
return $return;
}
示例10: setUp
public function setUp()
{
parent::setUp();
Yii::app()->user->userModel = User::getByUsername('super');
$emailBoxes = EmailBox::getAll();
$this->emailBox = $emailBoxes[0];
$this->marketingList = MarketingListTestHelper::createMarketingListByName('Test Marketing List');
}
示例11: testCreateEmailMessageThatIsANotification
/**
* A notification email is different than a regular outbound email because it is owned by a super user
* that is different than the user logged in. So the sender does not have a 'person'
*/
public function testCreateEmailMessageThatIsANotification()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$billy = User::getByUsername('billy');
$this->assertEquals(0, EmailMessage::getCount());
$emailMessage = new EmailMessage();
$emailMessage->owner = BaseControlUserConfigUtil::getUserToRunAs();
$emailMessage->subject = 'My First Email';
//Set sender, and recipient, and content
$emailContent = new EmailMessageContent();
$emailContent->textContent = 'My First Message';
$emailContent->htmlContent = 'Some fake HTML content';
$emailMessage->content = $emailContent;
//Sending from the system, does not have a 'person'.
$sender = new EmailMessageSender();
$sender->fromAddress = 'system@somewhere.com';
$sender->fromName = 'Zurmo System';
$emailMessage->sender = $sender;
//Recipient is billy.
$recipient = new EmailMessageRecipient();
$recipient->toAddress = 'billy@fakeemail.com';
$recipient->toName = 'Billy James';
$recipient->type = EmailMessageRecipient::TYPE_TO;
$recipient->personsOrAccounts->add($billy);
$emailMessage->recipients->add($recipient);
//At this point the message is in no folder
$this->assertTrue($emailMessage->folder->id < 0);
$box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
$emailMessage->folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_DRAFT);
//Save, at this point the email should be in the draft folder
$saved = $emailMessage->save();
$this->assertTrue($saved);
$this->assertTrue($emailMessage->folder->id > 0);
$this->assertEquals(0, EmailMessageSendError::getCount());
$emailMessageSendError = new EmailMessageSendError();
$data = array();
$data['message'] = 'error message';
$emailMessageSendError->serializedData = serialize($data);
$emailMessage->folder = EmailFolder::getByBoxAndType($emailMessage->folder->emailBox, EmailFolder::TYPE_OUTBOX_ERROR);
$emailMessage->error = $emailMessageSendError;
$saved = $emailMessage->save();
$this->assertTrue($saved);
$this->assertEquals(1, EmailMessageSendError::getCount());
//Now swap the error with a new one
$emailMessageId = $emailMessage->id;
$emailMessage->forget();
$emailMessage = EmailMessage::getById($emailMessageId);
$emailMessageSendError = new EmailMessageSendError();
$data = array();
$data['message'] = 'error message 2';
$emailMessageSendError->serializedData = serialize($data);
$emailMessage->error = $emailMessageSendError;
$saved = $emailMessage->save();
$this->assertTrue($saved);
$this->assertEquals(1, EmailMessageSendError::getCount());
}
示例12: setUp
public function setUp()
{
parent::setUp();
Yii::app()->user->userModel = User::getByUsername('super');
$emailBoxes = EmailBox::getAll();
$this->emailBox = $emailBoxes[0];
$this->marketingList = MarketingListTestHelper::createMarketingListByName('Test Marketing List');
$this->campaign = CampaignTestHelper::createCampaign('Test Campaing 01', 'text', 'text exemple');
$this->autoresponder = AutoresponderTestHelper::createAutoresponder('Test Autoresponder 01', 'text', 'html', 60, Autoresponder::OPERATION_SUBSCRIBE, true);
}
示例13: createBoxAndDefaultFoldersByUserAndName
/**
* Given a box name and user, create an email box with the default folders.
* @param User $user
* @param string $name
*/
public static function createBoxAndDefaultFoldersByUserAndName(User $user, $name)
{
assert('$user->id > 0');
assert('is_string($name)');
$box = new EmailBox();
$box->name = $name;
$box->user = $user;
$folder = new EmailFolder();
$folder->name = EmailFolder::getDefaultDraftName();
$folder->type = EmailFolder::TYPE_DRAFT;
$folder->emailBox = $box;
$box->folders->add($folder);
$folder = new EmailFolder();
$folder->name = EmailFolder::getDefaultInboxName();
$folder->type = EmailFolder::TYPE_INBOX;
$folder->emailBox = $box;
$box->folders->add($folder);
$folder = new EmailFolder();
$folder->name = EmailFolder::getDefaultSentName();
$folder->type = EmailFolder::TYPE_SENT;
$folder->emailBox = $box;
$box->folders->add($folder);
$folder = new EmailFolder();
$folder->name = EmailFolder::getDefaultOutboxName();
$folder->type = EmailFolder::TYPE_OUTBOX;
$folder->emailBox = $box;
$box->folders->add($folder);
$folder = new EmailFolder();
$folder->name = EmailFolder::getDefaultOutboxErrorName();
$folder->type = EmailFolder::TYPE_OUTBOX_ERROR;
$folder->emailBox = $box;
$box->folders->add($folder);
$folder = new EmailFolder();
$folder->name = EmailFolder::getDefaultOutboxFailureName();
$folder->type = EmailFolder::TYPE_OUTBOX_FAILURE;
$folder->emailBox = $box;
$box->folders->add($folder);
$folder = new EmailFolder();
$folder->name = EmailFolder::getDefaultArchivedName();
$folder->type = EmailFolder::TYPE_ARCHIVED;
$folder->emailBox = $box;
$box->folders->add($folder);
$folder = new EmailFolder();
$folder->name = EmailFolder::getDefaultArchivedUnmatchedName();
$folder->type = EmailFolder::TYPE_ARCHIVED_UNMATCHED;
$folder->emailBox = $box;
$box->folders->add($folder);
$saved = $box->save();
if (!$saved) {
throw new NotSupportedException();
}
return $box;
}
示例14: resolveSearchAttributeDataForAllLatestActivities
public function resolveSearchAttributeDataForAllLatestActivities($searchAttributeData)
{
assert('is_array($searchAttributeData)');
$box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
$searchAttributeData = parent::resolveSearchAttributeDataForAllLatestActivities($searchAttributeData);
$clausesCount = count($searchAttributeData['clauses']);
$searchAttributeData['clauses'][$clausesCount + 1] = array('attributeName' => 'folder', 'relatedModelData' => array('attributeName' => 'emailBox', 'operatorType' => 'doesNotEqual', 'value' => $box->id));
if ($searchAttributeData['structure'] != null) {
$searchAttributeData['structure'] .= ' and ';
}
$searchAttributeData['structure'] .= $clausesCount + 1;
return $searchAttributeData;
}
示例15: run
/**
*
* (non-PHPdoc)
* @see BaseJob::run()
*/
public function run()
{
$box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
$oneWeekAgoTimeStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 60 * 60 * 24 * 7);
$searchAttributeData = array();
$searchAttributeData['clauses'] = array(1 => array('attributeName' => 'modifiedDateTime', 'operatorType' => 'lessThan', 'value' => $oneWeekAgoTimeStamp), 2 => array('attributeName' => 'folder', 'relatedAttributeName' => 'type', 'operatorType' => 'equals', 'value' => EmailFolder::TYPE_SENT), 3 => array('attributeName' => 'folder', 'relatedAttributeName' => 'emailBox', 'operatorType' => 'equals', 'value' => $box->id));
$searchAttributeData['structure'] = '1 and 2 and 3';
$joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('EmailMessage');
$where = RedBeanModelDataProvider::makeWhere('EmailMessage', $searchAttributeData, $joinTablesAdapter);
$emailMessageModels = EmailMessage::getSubset($joinTablesAdapter, null, self::$pageSize, $where, null);
foreach ($emailMessageModels as $emailMessage) {
$emailMessage->delete();
}
return true;
}