本文整理汇总了PHP中Email::populateTemplate方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::populateTemplate方法的具体用法?PHP Email::populateTemplate怎么用?PHP Email::populateTemplate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Email
的用法示例。
在下文中一共展示了Email::populateTemplate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: notifyCommentRecipient
/**
* Send comment notification to a given recipient
*
* @param Comment $comment
* @param DataObject $parent Object with the {@see CommentNotifiable} extension applied
* @param Member|string $recipient Either a member object or an email address to which notifications should be sent
*/
public function notifyCommentRecipient($comment, $parent, $recipient)
{
$subject = $parent->notificationSubject($comment, $recipient);
$sender = $parent->notificationSender($comment, $recipient);
$template = $parent->notificationTemplate($comment, $recipient);
// Validate email
// Important in case of the owner being a default-admin or a username with no contact email
$to = $recipient instanceof Member ? $recipient->Email : $recipient;
if (!$this->isValidEmail($to)) {
return;
}
// Prepare the email
$email = new Email();
$email->setSubject($subject);
$email->setFrom($sender);
$email->setTo($to);
$email->setTemplate($template);
$email->populateTemplate(array('Parent' => $parent, 'Comment' => $comment, 'Recipient' => $recipient));
if ($recipient instanceof Member) {
$email->populateTemplate(array('ApproveLink' => $comment->ApproveLink($recipient), 'HamLink' => $comment->HamLink($recipient), 'SpamLink' => $comment->SpamLink($recipient), 'DeleteLink' => $comment->DeleteLink($recipient)));
}
// Until invokeWithExtensions supports multiple arguments
if (method_exists($this->owner, 'updateCommentNotification')) {
$this->owner->updateCommentNotification($email, $comment, $recipient);
}
$this->owner->extend('updateCommentNotification', $email, $comment, $recipient);
return $email->send();
}
示例2: createEmail
public function createEmail($subject = "Website Enquiry", $template = "GenericEmail")
{
$content = $this->renderWith("EnquiryEmail_content");
$to = Email::getAdminEmail();
$email = new Email($this->Email, $to, $subject);
$email->setTemplate($template);
$email->populateTemplate($this);
$email->populateTemplate(array('Body' => $content));
$this->extend('updateReceiptEmail', $email);
return $email;
}
示例3: run
public function run($request)
{
$sent = 0;
$filter = '"WorkflowStatus" IN (\'Active\', \'Paused\') AND "RemindDays" > 0';
$join = 'INNER JOIN "WorkflowDefinition" ON "DefinitionID" = "WorkflowDefinition"."ID"';
$active = DataObject::get('WorkflowInstance', $filter, null, $join);
if ($active) {
foreach ($active as $instance) {
$edited = strtotime($instance->LastEdited);
$days = $instance->Definition()->RemindDays;
if ($edited + $days * 3600 * 24 > time()) {
continue;
}
$email = new Email();
$bcc = '';
$members = $instance->getAssignedMembers();
$target = $instance->getTarget();
if (!$members || !count($members)) {
continue;
}
$email->setSubject("Workflow Reminder: {$instance->Title}");
$email->setBcc(implode(', ', $members->column('Email')));
$email->setTemplate('WorkflowReminderEmail');
$email->populateTemplate(array('Instance' => $instance, 'Link' => $target instanceof SiteTree ? "admin/show/{$target->ID}" : ''));
$email->send();
$sent++;
$instance->LastEdited = time();
$instance->write();
}
}
echo "Sent {$sent} workflow reminder emails.\n";
}
示例4: process
public function process()
{
$config = SiteConfig::current_site_config();
$datetime = $this->getDatetime();
$emails = $this->emails;
if (!count($emails)) {
$this->isComplete = true;
return;
}
$email = new Email();
$email->setSubject(sprintf(_t('EventManagement.EVENTREMINDERSUBJECT', 'Event Reminder For %s (%s)'), $datetime->EventTitle(), $config->Title));
$email->setTemplate('EventReminderEmail');
$email->populateTemplate(array('SiteConfig' => $config, 'Datetime' => $datetime));
foreach ($emails as $addr => $name) {
$_email = clone $email;
$_email->setTo($addr);
$_email->populateTemplate(array('Name' => $name));
$_email->send();
unset($emails[$addr]);
$this->emails = $emails;
++$this->currentStep;
}
if (!count($emails)) {
$this->isComplete = true;
}
}
示例5: run
public function run($request)
{
$sent = 0;
if (WorkflowInstance::get()->count()) {
// Don't attempt the filter if no instances -- prevents a crash
$active = WorkflowInstance::get()->innerJoin('WorkflowDefinition', '"DefinitionID" = "WorkflowDefinition"."ID"')->filter(array('WorkflowStatus' => array('Active', 'Paused'), 'RemindDays:GreaterThan' => '0'));
$active->filter(array('RemindDays:GreaterThan' => '0'));
if ($active) {
foreach ($active as $instance) {
$edited = strtotime($instance->LastEdited);
$days = $instance->Definition()->RemindDays;
if ($edited + $days * 3600 * 24 > time()) {
continue;
}
$email = new Email();
$bcc = '';
$members = $instance->getAssignedMembers();
$target = $instance->getTarget();
if (!$members || !count($members)) {
continue;
}
$email->setSubject("Workflow Reminder: {$instance->Title}");
$email->setBcc(implode(', ', $members->column('Email')));
$email->setTemplate('WorkflowReminderEmail');
$email->populateTemplate(array('Instance' => $instance, 'Link' => $target instanceof SiteTree ? "admin/show/{$target->ID}" : ''));
$email->send();
$sent++;
$instance->LastEdited = time();
$instance->write();
}
}
}
echo "Sent {$sent} workflow reminder emails.\n";
}
示例6: onBeforeWrite
public function onBeforeWrite()
{
if ($this->owner->BaseClass == "Discussion" && $this->owner->ID == 0) {
$discussion = Discussion::get()->byID($this->owner->ParentID);
$discussion_author = $discussion->Author();
$holder = $discussion->Parent();
$author = Member::get()->byID($this->owner->AuthorID);
// Get our default email from address
if (DiscussionHolder::config()->send_emails_from) {
$from = DiscussionHolder::config()->send_email_from;
} else {
$from = Email::config()->admin_email;
}
// Vars for the emails
$vars = array("Title" => $discussion->Title, "Author" => $author, "Comment" => $this->owner->Comment, 'Link' => Controller::join_links($holder->Link("view"), $discussion->ID, "#comments-holder"));
// Send email to discussion owner
if ($discussion_author && $discussion_author->Email && $discussion_author->RecieveCommentEmails && $discussion_author->ID != $this->owner->AuthorID) {
$subject = _t("Discussions.NewCreatedReplySubject", "{Nickname} replied to your discussion", null, array("Nickname" => $author->Nickname));
$email = new Email($from, $discussion_author->Email, $subject);
$email->setTemplate('NewCreatedReplyEmail');
$email->populateTemplate($vars);
$email->send();
}
// Send to anyone who liked this, if they want notifications
foreach ($discussion->LikedBy() as $liked) {
if ($liked->RecieveLikedReplyEmails && $liked->Email && $liked->ID != $author->ID) {
$subject = _t("Discussions.NewLikedReplySubject", "{Nickname} replied to your liked discussion", null, array("Nickname" => $author->Nickname));
$email = new Email($from, $liked->Email, $subject);
$email->setTemplate('NewLikedReplyEmail');
$email->populateTemplate($vars);
$email->send();
}
}
}
}
示例7: onAfterPostComment
/**
* Notify admin of new comment
*
* @param Comment $comment
*/
public function onAfterPostComment(Comment $comment)
{
// Determine recipient
$recipient = CommentsNotifications::get_recipient($comment->getParent());
if (empty($recipient)) {
return;
}
// Check moderation status
if (Config::inst()->get('CommentsNotifications', 'only_unmoderated') && $comment->Moderated) {
return;
}
// Generate email
$email = new Email();
$email->setSubject(Config::inst()->get('CommentsNotifications', 'email_subject'));
$email->setTo($recipient);
$email->setTemplate(Config::inst()->get('CommentsNotifications', 'email_template'));
$email->populateTemplate($comment);
// Corretly set sender and from as per email convention
$sender = Config::inst()->get('CommentsNotifications', 'email_sender');
if (!empty($comment->Email)) {
$email->setFrom($comment->Email);
$email->addCustomHeader('Reply-To', $comment->Email);
} else {
$email->setFrom($sender);
}
$email->addCustomHeader('X-Sender', $sender);
$email->addCustomHeader('Sender', $sender);
$this->owner->extend('updateEmail', $email);
// Send
$email->send();
}
开发者ID:helpfulrobot,项目名称:tractorcow-silverstripe-comments-notifications,代码行数:36,代码来源:CommentingControllerNotificationsExtension.php
示例8: dosave
/**
* Form action handler for ContactInquiryForm.
*
* @param array $data The form request data submitted
* @param Form $form The {@link Form} this was submitted on
*/
function dosave(array $data, Form $form, SS_HTTPRequest $request)
{
$SQLData = Convert::raw2sql($data);
$attrs = $form->getAttributes();
if ($SQLData['Comment'] != '' || $SQLData['Url'] != '') {
// most probably spam - terminate silently
Director::redirect(Director::baseURL() . $this->URLSegment . "/success");
return;
}
$item = new ContactInquiry();
$form->saveInto($item);
// $form->sessionMessage(_t("ContactPage.FORMMESSAGEGOOD", "Your inquiry has been submitted. Thanks!"), 'good');
$item->write();
$mailFrom = $this->currController->MailFrom ? $this->currController->MailFrom : $SQLData['Email'];
$mailTo = $this->currController->MailTo ? $this->currController->MailTo : Email::getAdminEmail();
$mailSubject = $this->currController->MailSubject ? $this->currController->MailSubject . ' - ' . $SQLData['Ref'] : _t('ContactPage.SUBJECT', '[web] New contact inquiry - ') . ' ' . $data['Ref'];
$email = new Email($mailFrom, $mailTo, $mailSubject);
$email->replyTo($SQLData['Email']);
$email->setTemplate("ContactInquiry");
$email->populateTemplate($SQLData);
$email->send();
// $this->controller->redirectBack();
if ($email->send()) {
$this->controller->redirect($this->controller->Link() . "success");
} else {
$this->controller->redirect($this->controller->Link() . "error");
}
return false;
}
示例9: validateStep
/**
* This does not actually perform any validation, but just creates the
* initial registration object.
*/
public function validateStep($data, $form)
{
$form = $this->getForm();
$datetime = $form->getController()->getDateTime();
$confirmation = $datetime->Event()->RegEmailConfirm;
$registration = $this->getForm()->getSession()->getRegistration();
// If we require email validation for free registrations, then send
// out the email and mark the registration. Otherwise immediately
// mark it as valid.
if ($confirmation) {
$email = new Email();
$config = SiteConfig::current_site_config();
$registration->TimeID = $datetime->ID;
$registration->Status = 'Unconfirmed';
$registration->write();
if (Member::currentUserID()) {
$details = array('Name' => Member::currentUser()->getName(), 'Email' => Member::currentUser()->Email);
} else {
$details = $form->getSavedStepByClass('EventRegisterTicketsStep');
$details = $details->loadData();
}
$link = Controller::join_links($this->getForm()->getController()->Link(), 'confirm', $registration->ID, '?token=' . $registration->Token);
$regLink = Controller::join_links($datetime->Event()->Link(), 'registration', $registration->ID, '?token=' . $registration->Token);
$email->setTo($details['Email']);
$email->setSubject(sprintf('Confirm Registration For %s (%s)', $datetime->getTitle(), $config->Title));
$email->setTemplate('EventRegistrationConfirmationEmail');
$email->populateTemplate(array('Name' => $details['Name'], 'Registration' => $registration, 'RegLink' => $regLink, 'Title' => $datetime->getTitle(), 'SiteConfig' => $config, 'ConfirmLink' => Director::absoluteURL($link)));
$email->send();
Session::set("EventRegistration.{$registration->ID}.message", $datetime->Event()->EmailConfirmMessage);
} else {
$registration->Status = 'Valid';
$registration->write();
}
return true;
}
示例10: doSubmitContactForm
public function doSubmitContactForm($data, Form $form)
{
$subject = !empty($this->Subject) ? $this->Subject : 'Contact form submission';
$email = new Email($this->getEmailFrom($data), $this->getEmailTo($data), $subject);
$email->setTemplate('ContactForm');
$email->populateTemplate(array('Body' => $this->buildEmailBody($data)));
$email->send();
Controller::redirect($this->Link("?success=1"));
}
示例11: sendMailtoAuthors
/**
* Sending mail after extension is approved.
*
* @param array $mailData
*/
private function sendMailtoAuthors($mailData)
{
$From = $mailData['From'];
$To = $mailData['To'];
$Subject = $mailData['Subject'];
$email = new Email($From, $To, $Subject);
$email->setTemplate('ExtensionApproved');
$email->populateTemplate($mailData);
$email->send();
}
示例12: SendContactForm
function SendContactForm($data, $form)
{
$From = $data['Email'];
$To = $this->Mailto;
//$To = "andres@laclaqueta.com";
$Subject = $this->subjects[$data['Subject']];
$email = new Email($From, $To, $Subject);
$email->setTemplate('ContactEmail');
$email->populateTemplate($data);
$email->send();
//$this->SubmitText = "Los datos se ha enviado correctamente";
$this->redirect($this->Link("?success=1"));
}
示例13: notifyCommentRecipient
/**
* Send comment notification to a given recipient
*
* @param BlogGuestBookSubmission $submission
* @param DataObject $parent Object with the {@see CommentNotifiable} extension applied
* @param Member|string $recipient Either a member object or an email address to which notifications should be sent
*/
public function notifyCommentRecipient($submission, $parent, $recipient)
{
$subject = $parent->NotificationSubject;
$sender = $submission->Email;
$template = "BlogGuestBlogEmail";
// Validate email
// Important in case of the owner being a default-admin or a username with no contact email
$to = $recipient->EmailAddress;
if (!$this->isValidEmail($to)) {
return;
}
// Prepare the email
$email = new Email();
$email->setSubject($subject);
$email->setFrom($sender);
$email->setTo($to);
$email->setTemplate($template);
$email->populateTemplate(array('Parent' => $parent, 'Submission' => $submission, 'Recipient' => $recipient));
if ($recipient instanceof Member) {
$email->populateTemplate(array('ApproveLink' => $submission->ApproveLink($recipient), 'HamLink' => $submission->HamLink($recipient), 'SpamLink' => $submission->SpamLink($recipient), 'DeleteLink' => $submission->DeleteLink($recipient)));
}
return $email->send();
}
示例14: notifyOwner
/**
* @param int $ownerID
* @param array|SS_List $pages
*/
protected function notifyOwner($ownerID, SS_List $pages)
{
$owner = self::$member_cache[$ownerID];
$sender = Security::findAnAdministrator();
$senderEmail = $sender->Email ? $sender->Email : Config::inst()->get("Email", "admin_email");
$subject = _t("ContentReviewEmails.SUBJECT", "Page(s) are due for content review");
$email = new Email();
$email->setTo($owner->Email);
$email->setFrom($senderEmail);
$email->setTemplate("ContentReviewEmail");
$email->setSubject($subject);
$email->populateTemplate(array("Recipient" => $owner, "Sender" => $sender, "Pages" => $pages));
$email->send();
}
示例15: doContact
function doContact($data, $form)
{
//Send an email to the support
$email = new Email();
$email->setSubject("Contact Us form submitted");
$email->setFrom($data['Email']);
$email->setTo('support@attentionwizard.com');
//$email->setTo('hemant.chakka@yahoo.com');
$email->setTemplate('ContactUsEmail');
$email->populateTemplate(array('Name' => $data['Name'], 'Email' => $data['Email'], 'Phone' => $data['Phone'], 'Topic' => $data['Topic'], 'Message' => $data['Message']));
$email->send();
$form->sessionMessage('Your email has been sent. Thank you for your message. Someone will respond back to you within 24-48 hours.', 'success');
return $this->redirectBack();
}