本文整理汇总了PHP中EmailFolder类的典型用法代码示例。如果您正苦于以下问题:PHP EmailFolder类的具体用法?PHP EmailFolder怎么用?PHP EmailFolder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EmailFolder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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);
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:31,代码来源:ProcessOutboundEmailJobTest.php
示例2: 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 = '[email protected]';
$sender->fromName = 'Zurmo System';
$emailMessage->sender = $sender;
//Recipient is billy.
$recipient = new EmailMessageRecipient();
$recipient->toAddress = '[email protected]';
$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;
}
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:30,代码来源:SendGridTestHelper.php
示例3: 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;
}
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:40,代码来源:EmailMessageUtil.php
示例4: 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 = '[email protected]';
$sender->fromName = 'Zurmo System';
$sender->personsOrAccounts->add($super);
$emailMessage->sender = $sender;
//Recipient is billy.
$recipient = new EmailMessageRecipient();
$recipient->toAddress = '[email protected]';
$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');
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:38,代码来源:ActivitiesUtilTest.php
示例5: 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 CreateEmailMessageForm $emailMessageForm
* @param User $userToSendMessagesFrom
* @return CreateEmailMessageForm
*/
public static function resolveEmailMessageFromPostData(array &$postData, CreateEmailMessageForm $emailMessageForm, User $userToSendMessagesFrom)
{
$postVariableName = get_class($emailMessageForm);
$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 = $emailAccount->fromName;
$sender->fromAddress = $emailAccount->fromAddress;
$sender->personsOrAccounts->add($userToSendMessagesFrom);
$emailMessageForm->sender = $sender;
$emailMessageForm->account = $emailAccount;
$box = EmailBoxUtil::getDefaultEmailBoxByUser($userToSendMessagesFrom);
$emailMessageForm->folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_OUTBOX);
return $emailMessageForm;
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:38,代码来源:EmailMessageUtil.php
示例6: 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);
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:26,代码来源:ClearSentNotificationsEmailJobTest.php
示例7: renderControlNonEditable
protected function renderControlNonEditable()
{
assert('$this->model instanceof EmailMessage');
if ($this->model->folder->type == EmailFolder::TYPE_SENT) {
return parent::renderControlNonEditable();
}
return Zurmo::t('EmailMessagesModule', 'Currently in the {folderType} folder', array('{folderType}' => EmailFolder::getTranslatedFolderNameByType($this->model->folder->type)));
}
开发者ID:youprofit,项目名称:Zurmo,代码行数:8,代码来源:EmailMessageSentDateTimeElement.php
示例8: init
public function init()
{
$this->uid = $uid = intval(Yii::app()->user->uid);
$this->folders = EmailFolder::model()->fetchAllUserFolderByUid($uid);
$this->allowWebMail = (bool) Yii::app()->setting->get("setting/emailexternalmail");
$this->webMails = $this->allowWebMail ? EmailWeb::model()->fetchAllByUid($uid) : array();
parent::init();
}
开发者ID:AxelPanda,项目名称:ibos,代码行数:8,代码来源:EmailBaseController.php
示例9: sendEmail
/**
* Override to avoid actually sending emails out through transport.
* (non-PHPdoc)
* @see EmailHelper::sendEmail()
*/
protected function sendEmail(Mailer $mailer, EmailMessage $emailMessage)
{
if (!$this->sendEmailThroughTransport) {
$emailMessage->error = null;
$emailMessage->folder = EmailFolder::getByBoxAndType($emailMessage->folder->emailBox, EmailFolder::TYPE_SENT);
} else {
parent::sendEmail($mailer, $emailMessage);
}
}
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:14,代码来源:EmailHelperForTesting.php
示例10: sendEmail
/**
* Override to avoid actually sending emails out through transport.
* (non-PHPdoc)
* @see ZurmoSwiftMailer::sendEmail()
*/
public function sendEmail()
{
$emailMessage = $this->emailMessage;
$sendEmailThroughTransport = Yii::app()->emailHelper->sendEmailThroughTransport;
if (!$sendEmailThroughTransport) {
$emailMessage->error = null;
$emailMessage->folder = EmailFolder::getByBoxAndType($emailMessage->folder->emailBox, EmailFolder::TYPE_SENT);
$emailMessage->sendAttempts = $emailMessage->sendAttempts + 1;
$emailMessage->save();
} else {
parent::sendEmail();
}
}
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:18,代码来源:ZurmoSwiftMailerForTesting.php
示例11: actionDel
public function actionDel()
{
$fid = $this->fid;
$cleanAll = EnvUtil::getRequest("delemail");
$emailIds = Email::model()->fetchAllEmailIdsByFolderId($fid, $this->uid);
if ($cleanAll) {
$emailIds && Email::model()->completelyDelete($emailIds, $this->uid);
} else {
$emailIds && Email::model()->updateByPk($emailIds, array("fid" => parent::INBOX_ID));
}
$deleted = EmailFolder::model()->deleteByPk($fid);
if ($deleted) {
$this->ajaxReturn(array("isSuccess" => true));
} else {
$this->ajaxReturn(array("isSuccess" => false, "errorMsg" => Ibos::lang("Del failed", "message")));
}
}
开发者ID:AxelPanda,项目名称:ibos,代码行数:17,代码来源:FolderController.php
示例12: process
/**
* @throws MissingRecipientsForEmailMessageException
*/
public function process()
{
$emailTemplate = EmailTemplate::getById((int) $this->emailMessageForm->emailTemplateId);
$emailMessage = new EmailMessage();
$emailMessage->owner = $this->triggeredByUser;
$emailMessage->subject = $this->resolveEmailTemplateSubjectForModelData($emailTemplate);
$emailContent = new EmailMessageContent();
$emailContent->textContent = $this->resolveEmailTemplateTextContentForModelData($emailTemplate);
$emailContent->htmlContent = $this->resolveEmailTemplateHtmlContentForModelData($emailTemplate);
$emailMessage->content = $emailContent;
$emailMessage->sender = $this->resolveSender();
$this->resolveRecipients($emailMessage);
if ($emailMessage->recipients->count() == 0) {
throw new MissingRecipientsForEmailMessageException();
}
$box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
$emailMessage->folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_DRAFT);
Yii::app()->emailHelper->send($emailMessage);
}
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:22,代码来源:WorkflowEmailMessageProcessingHelper.php
示例13: testExportRelationAttributes
public function testExportRelationAttributes()
{
$report = new Report();
$report->setType(Report::TYPE_ROWS_AND_COLUMNS);
$report->setModuleClassName('EmailMessagesModule');
$report->setFiltersStructure('');
$emailMessage = new EmailMessage();
$emailMessage->owner = Yii::app()->user->userModel;
$emailMessage->subject = 'A test email';
$emailContent = new EmailMessageContent();
$emailContent->textContent = 'A test text message from Zurmo.';
$emailContent->htmlContent = 'A test text message from Zurmo.';
$emailMessage->content = $emailContent;
$sender = new EmailMessageSender();
$sender->fromAddress = '[email protected]';
$sender->fromName = 'super';
$sender->personsOrAccounts->add(Yii::app()->user->userModel);
$emailMessage->sender = $sender;
$recipient = new EmailMessageRecipient();
$recipient->toAddress = '[email protected]';
$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_SENT);
$this->assertTrue($emailMessage->save());
$displayAttribute1 = new DisplayAttributeForReportForm('EmailMessagesModule', 'EmailMessage', Report::TYPE_ROWS_AND_COLUMNS);
$displayAttribute1->setModelAliasUsingTableAliasName('relatedModel');
$displayAttribute1->attributeIndexOrDerivedType = 'sender___User__personsOrAccounts__Inferred___firstName';
$report->addDisplayAttribute($displayAttribute1);
$displayAttribute2 = new DisplayAttributeForReportForm('EmailMessagesModule', 'EmailMessage', Report::TYPE_ROWS_AND_COLUMNS);
$displayAttribute2->setModelAliasUsingTableAliasName('relatedModel');
$displayAttribute2->attributeIndexOrDerivedType = 'sender___Contact__personsOrAccounts__Inferred___firstName';
$report->addDisplayAttribute($displayAttribute2);
$dataProvider = new RowsAndColumnsReportDataProvider($report);
$adapter = ReportToExportAdapterFactory::createReportToExportAdapter($report, $dataProvider);
$compareHeaderData = array('Sender >> Users >> First Name', 'Sender >> Contacts >> First Name');
$compareRowData = array(array('Clark', ''));
$this->assertEquals($compareHeaderData, $adapter->getHeaderData());
$this->assertEquals($compareRowData, $adapter->getData());
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:41,代码来源:EmailMessagesRowsAndColumnsReportToExportAdapterTest.php
示例14: makeEmailMessage
protected function makeEmailMessage(Contact $contact, $subject = null)
{
$interval = mt_rand(4, 35) * 86400;
if (!isset($subject)) {
$subject = 'A test archived sent email';
}
//#1 Create Archived - Sent
$emailMessage = new EmailMessage();
$emailMessage->setScenario('importModel');
$emailMessage->owner = $contact->owner;
$emailMessage->subject = $subject;
$emailContent = new EmailMessageContent();
$emailContent->textContent = 'My First Message';
$emailContent->htmlContent = 'Some fake HTML content';
$emailMessage->content = $emailContent;
//Sending is current user (super)
$sender = new EmailMessageSender();
$sender->fromAddress = '[email protected]';
$sender->fromName = 'Super User';
$sender->personsOrAccounts->add(Yii::app()->user->userModel);
$emailMessage->sender = $sender;
//Recipient is BobMessage
$recipient = new EmailMessageRecipient();
$recipient->toAddress = '[email protected]';
$recipient->toName = strval($contact);
$recipient->personsOrAccounts->add($contact);
$recipient->type = EmailMessageRecipient::TYPE_TO;
$emailMessage->recipients->add($recipient);
$emailMessage->folder = EmailFolder::getByBoxAndType($this->emailBox, EmailFolder::TYPE_SENT);
$emailMessage->createdDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - $interval);
$emailMessage->sentDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - $interval + mt_rand(0, 3) * 86400);
$emailMessage->addPermissions(Group::getByName(Group::EVERYONE_GROUP_NAME), Permission::READ_WRITE_CHANGE_PERMISSIONS_CHANGE_OWNER);
$saved = $emailMessage->save();
if (!$saved) {
throw new FailedToSaveModelException();
}
$emailMessage = EmailMessage::getById($emailMessage->id);
AllPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($emailMessage, Group::getByName(Group::EVERYONE_GROUP_NAME));
$emailMessage->save();
return $emailMessage;
}
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:41,代码来源:EmailMessageActivitiesDemoDataMaker.php
示例15: 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 = Yii::app()->emailHelper->resolveFromNameForSystemUser($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);
$validatedAndSaved = $emailMessage->save();
if (!$validatedAndSaved) {
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:RamaKavanan,项目名称:InitialVersion,代码行数:42,代码来源:TestOutboundEmailJob.php
示例16: createEmailMessage
private function createEmailMessage($contact, $emailMessageSentDateTime)
{
$emailBox = $this->emailBox;
$emailMessage = new EmailMessage();
$emailMessage->setScenario('importModel');
$emailContent = new EmailMessageContent();
$emailContent->textContent = 'My First Message';
$emailContent->htmlContent = 'Some fake HTML content';
$sender = new EmailMessageSender();
$sender->fromAddress = '[email protected]';
$sender->fromName = 'Super User';
$sender->personOrAccount = Yii::app()->user->userModel;
$recipient = new EmailMessageRecipient();
$recipient->toAddress = '[email protected]';
$recipient->toName = strval($contact);
$recipient->personOrAccount = $contact;
$recipient->type = EmailMessageRecipient::TYPE_TO;
$emailMessage->owner = Yii::app()->user->userModel;
$emailMessage->subject = 'A test archived sent email';
$emailMessage->content = $emailContent;
$emailMessage->sender = $sender;
if (isset($emailMessageSentDateTime)) {
$emailMessage->sentDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(strtotime($emailMessageSentDateTime));
$emailMessage->createdDateTime = $emailMessage->sentDateTime;
}
$emailMessage->folder = EmailFolder::getByBoxAndType($emailBox, EmailFolder::TYPE_ARCHIVED);
$emailMessage->recipients->add($recipient);
return $emailMessage;
}
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:29,代码来源:MarketingEmailsInThisListChartDataProviderTest.php
示例17: resolveAndSendEmail
/**
* @param User $senderPerson
* @param array $recipients
* @param string $subject
* @param EmailMessageContent $content
*/
public static function resolveAndSendEmail($senderPerson, $recipients, $subject, $content)
{
assert('$senderPerson instanceof User');
assert('is_array($recipients)');
assert('is_string($subject)');
assert('$content instanceof EmailMessageContent');
if (count($recipients) == 0) {
return;
}
$userToSendMessagesFrom = $senderPerson;
$emailMessage = new EmailMessage();
$emailMessage->owner = $senderPerson;
$emailMessage->subject = $subject;
$emailMessage->content = $content;
$sender = new EmailMessageSender();
$sender->fromAddress = Yii::app()->emailHelper->resolveFromAddressByUser($userToSendMessagesFrom);
$sender->fromName = strval($userToSendMessagesFrom);
$sender->personsOrAccounts->add($userToSendMessagesFrom);
$emailMessage->sender = $sender;
foreach ($recipients as $recipientPerson) {
$recipient = new EmailMessageRecipient();
$recipient->toAddress = $recipientPerson->primaryEmail->emailAddress;
$recipient->toName = strval($recipientPerson);
$recipient->type = EmailMessageRecipient::TYPE_TO;
$recipient->personsOrAccounts->add($recipientPerson);
$emailMessage->recipients->add($recipient);
}
$box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
$emailMessage->folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_DRAFT);
Yii::app()->emailHelper->send($emailMessage);
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:37,代码来源:EmailNotificationUtil.php
示例18: sendTaskEmail
/**
* Send task email
* @param Notification $notification
* @param TaskNotificationRules $rule
* @param string $action
*/
protected static function sendTaskEmail(Notification $notification, TaskNotificationRules $rule, $action)
{
assert('is_string($action)');
if ($notification->owner->primaryEmail->emailAddress !== null && !UserConfigurationFormAdapter::resolveAndGetValue($notification->owner, 'turnOffEmailNotifications')) {
$emailMessage = static::makeEmailMessage($notification, $rule, $action);
$emailMessage->content = static::makeEmailContent($notification);
$emailMessage->sender = static::makeSender();
$emailMessage->recipients->add(static::makeRecipient($notification));
$box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
$emailMessage->folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_DRAFT);
try {
Yii::app()->emailHelper->send($emailMessage);
} catch (CException $e) {
//Not sure what to do yet when catching an exception here. Currently ignoring gracefully.
}
}
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:23,代码来源:TasksNotificationUtil.php
示例19: resolveEmailMessage
protected static function resolveEmailMessage($textContent, $htmlContent, Autoresponder $autoresponder, Contact $contact)
{
$marketingList = $autoresponder->marketingList;
$emailMessage = new EmailMessage();
$emailMessage->owner = $marketingList->owner;
$emailMessage->subject = $autoresponder->subject;
$emailContent = new EmailMessageContent();
$emailContent->textContent = $textContent;
$emailContent->htmlContent = $htmlContent;
$emailMessage->content = $emailContent;
$emailMessage->sender = static::resolveSender($marketingList);
static::resolveRecipient($emailMessage, $contact);
if ($emailMessage->recipients->count() == 0) {
throw new MissingRecipientsForEmailMessageException();
}
$box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
$emailMessage->folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_DRAFT);
Yii::app()->emailHelper->send($emailMessage);
return $emailMessage;
}
开发者ID:youprofit,项目名称:Zurmo,代码行数:20,代码来源:AutoresponderItemsUtil.php
示例20: 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
注:本文中的EmailFolder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论