當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Email::setBody方法代碼示例

本文整理匯總了PHP中Email::setBody方法的典型用法代碼示例。如果您正苦於以下問題:PHP Email::setBody方法的具體用法?PHP Email::setBody怎麽用?PHP Email::setBody使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Email的用法示例。


在下文中一共展示了Email::setBody方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: form

 public function form(SS_HTTPRequest $request)
 {
     /*		
     		echo "<pre>";
     		echo print_r($request);
     		echo "<hr>";
     		echo print_r($_POST);
     		echo "</pre>";
     		echo $_SERVER['HTTP_REFERER'];
     */
     $data = $_POST;
     $email = new Email();
     $email->setTo('mail@nobrainer.dk');
     $email->setFrom($data['Email']);
     $email->setSubject("Contact Message from " . $data["Name"]);
     $messageBody = "\n\t\t\t<p><strong>Name:</strong> {$data['Name']}</p>\n\t\t\t<p><strong>Message:</strong> {$data['Message']}</p>\n\t\t";
     $email->setBody($messageBody);
     $email->send();
     /*		return array(
     			'Content' => '<p>Thank you for your feedback.</p>',
     			'Form' => ''
     		);
     */
     $this->redirect($_SERVER['HTTP_REFERER'] . "?status=success");
 }
開發者ID:helpfulrobot,項目名稱:kendu-silverstripe-content-blocks,代碼行數:25,代碼來源:BlockController.php

示例2: sendToUser

 /**
  * Send a notification directly to a single user
  *
  * @param SystemNotification $notification
  * @param string $email
  * @param array $data
  */
 public function sendToUser($notification, $context, $user, $data)
 {
     $subject = $notification->format($notification->Title, $context, $user, $data);
     if (Config::inst()->get('SystemNotification', 'html_notifications')) {
         $message = $notification->format($notification->NotificationContent(), $context, $user, $data);
     } else {
         $message = $notification->format(nl2br($notification->NotificationContent()), $context, $user, $data);
     }
     if ($template = $notification->getTemplate()) {
         $templateData = $notification->getTemplateData($context, $user, $data);
         $templateData->setField('Body', $message);
         try {
             $body = $templateData->renderWith($template);
         } catch (Exception $e) {
             $body = $message;
         }
     } else {
         $body = $message;
     }
     $from = $this->config()->get('send_notifications_from');
     $to = $user->Email;
     if (!$to && method_exists($user, 'getEmailAddress')) {
         $to = $user->getEmailAddress();
     }
     // log
     $message = "Sending {$subject} to {$to}";
     SS_Log::log($message, SS_Log::NOTICE);
     // send
     $email = new Email($from, $to, $subject);
     $email->setBody($body);
     $this->extend('onBeforeSendToUser', $email);
     $email->send();
 }
開發者ID:helpfulrobot,項目名稱:sheadawson-silverstripe-notifications,代碼行數:40,代碼來源:EmailNotificationSender.php

示例3: SendAutoResponder

 public static function SendAutoResponder($subject = false, $body = false, $EmailFormTo = false)
 {
     $arr_path = explode(".", $_SERVER['HTTP_HOST']);
     $email = new Email("forms@" . $arr_path[1] . "." . $arr_path[2], $EmailFormTo, $subject);
     $email_body = "<html><body>";
     $email_body .= $body;
     $email_body .= "</body></html>";
     $email->setBody($email_body);
     $email->send();
 }
開發者ID:helpfulrobot,項目名稱:iqnection-pages-basepages,代碼行數:10,代碼來源:FormUtilities.php

示例4: sendEmail

 function sendEmail($data, $form)
 {
     $email = new Email();
     $email->setTo($data['Email']);
     $email->setFrom($data['Email']);
     $email->setSubject('A subject with some umlauts: öäüß');
     $email->setBody('A body with some umlauts: öäüß');
     $email->send();
     echo "<p>email sent to " . $data['Email'] . "</p>";
 }
開發者ID:normann,項目名稱:silverstripe-frameworktest,代碼行數:10,代碼來源:TestPage.php

示例5: sendPushNotification

 public function sendPushNotification(PushNotification $notification)
 {
     $email = new Email();
     $email->setFrom($this->getSetting('From'));
     $email->setSubject($this->getSetting('Subject'));
     $email->setBody($notification->Content);
     foreach ($notification->getRecipients() as $recipient) {
         $email->setTo($recipient->Email);
         $email->send();
     }
 }
開發者ID:silverstripe-australia,項目名稱:silverstripe-push,代碼行數:11,代碼來源:EmailPushProvider.php

示例6: submit

 public function submit($data, $form)
 {
     $email = new Email();
     $email->setTo('colletwebpro@gmail.com');
     $email->setFrom($data['Email']);
     $email->setSubject("Contact Message from {$data["Name"]}");
     $messageBody = " \n            <p><strong>Name:</strong> {$data['Name']}</p> \n            <p><strong>Message:</strong> {$data['Message']}</p> \n        ";
     $email->setBody($messageBody);
     $email->send();
     return array('Content' => '<p>Thank you for your feedback.</p>', 'Form' => '');
 }
開發者ID:Geitz,項目名稱:webdev_repo,代碼行數:11,代碼來源:ContactPage.php

示例7: sendEmail

 public function sendEmail($data, Form $form)
 {
     $email = new Email();
     $email->setTo('info@onboard.net.nz');
     $email->setFrom($data['Email']);
     $email->setSubject("Contact Message from {$data["Name"]}");
     $messageBody = "\n            <p><strong>Name:</strong> {$data['Name']}</p>\n            <p><strong>Email:</strong> {$data['Email']}</p>\n            <p><strong>Phone:</strong> {$data['Phone']}</p>\n            <p><strong>School:</strong> {$data['School']}</p>\n            <p><strong>Module:</strong> {$data['Module']}</p>\n            <p><strong>Message:</strong> {$data['Message']}</p>\n            ";
     $email->setBody($messageBody);
     $email->send();
     return array('Content' => '<p>Thank you for your feedback.</p>', 'Form' => '');
 }
開發者ID:dunatron,項目名稱:onbaord-revamp,代碼行數:11,代碼來源:Page.php

示例8: doContact

 public function doContact(array $data)
 {
     $email = new Email();
     $email->setTo(Email::getAdminEmail());
     $email->setFrom($data['Email']);
     $email->setSubject(_t('ContactForm.SUBJECT', 'ContactForm.SUBJECT') . $data['Name']);
     $email->setBody($data['Message']);
     //$email->set
     $email->send();
     $this->sessionMessage(_t('ContactForm.SUCCESS', 'ContactForm.SUCCESS'), 'good');
     $this->controller->redirectBack();
 }
開發者ID:andrelohmann,項目名稱:roof-for-refugees.org,代碼行數:12,代碼來源:ContactForm.php

示例9: main

 protected function main()
 {
     $o = $this->mailerQueue->getNext("lock_" . $this->pid);
     if (!$o) {
         return 5000000;
     }
     $email = new Email($o->from, $o->to, $o->subject, null, null);
     $email->setHeaders($o->headers);
     $email->setBody($o->body);
     Mailer::smtp($email);
     $this->mailerQueue->markSent($o->id);
     return 0;
 }
開發者ID:robkaper,項目名稱:kiki,代碼行數:13,代碼來源:maildaemon.php

示例10: execute

 public function execute(WorkflowInstance $workflow)
 {
     $members = $workflow->getAssignedMembers();
     if (!$members || !count($members)) {
         return true;
     }
     $member = Member::currentUser();
     $initiator = $workflow->Initiator();
     $contextFields = $this->getContextFields($workflow->getTarget());
     $memberFields = $this->getMemberFields($member);
     $initiatorFields = $this->getMemberFields($initiator);
     $variables = array();
     foreach ($contextFields as $field => $val) {
         $variables["\$Context.{$field}"] = $val;
     }
     foreach ($memberFields as $field => $val) {
         $variables["\$Member.{$field}"] = $val;
     }
     foreach ($initiatorFields as $field => $val) {
         $variables["\$Initiator.{$field}"] = $val;
     }
     $pastActions = $workflow->Actions()->sort('Created DESC');
     $variables["\$CommentHistory"] = $this->customise(array('PastActions' => $pastActions, 'Now' => SS_Datetime::now()))->renderWith('CommentHistory');
     $from = str_replace(array_keys($variables), array_values($variables), $this->EmailFrom);
     $subject = str_replace(array_keys($variables), array_values($variables), $this->EmailSubject);
     if ($this->config()->whitelist_template_variables) {
         $item = new ArrayData(array('Initiator' => new ArrayData($initiatorFields), 'Member' => new ArrayData($memberFields), 'Context' => new ArrayData($contextFields), 'CommentHistory' => $variables["\$CommentHistory"]));
     } else {
         $item = $workflow->customise(array('Items' => $workflow->Actions(), 'Member' => $member, 'Context' => new ArrayData($contextFields), 'CommentHistory' => $variables["\$CommentHistory"]));
     }
     if ($this->ListingTemplateID) {
         $template = DataObject::get_by_id('ListingTemplate', $this->ListingTemplateID);
         $view = SSViewer::fromString($template->ItemTemplate);
     } else {
         $view = SSViewer::fromString($this->EmailTemplate);
     }
     $body = $view->process($item);
     foreach ($members as $member) {
         if ($member->Email) {
             $email = new Email();
             $email->setTo($member->Email);
             $email->setSubject($subject);
             $email->setFrom($from);
             $email->setBody($body);
             $email->send();
         }
     }
     return true;
 }
開發者ID:Neumes,項目名稱:advancedworkflow,代碼行數:49,代碼來源:NotifyUsersWorkflowAction.php

示例11: testSendErrors

 /**
  * Tests possible sending errors.
  */
 public function testSendErrors()
 {
     $email = new Email();
     $email->setBody(new Email\Body(''));
     $sender = new Sender();
     $sender->setEmail($email);
     // Non-existent sending method
     try {
         $sender->send('dummy-mode');
         $this->fail(sprintf('Expected exception %s.', \InvalidArgumentException::class));
     } catch (\PHPUnit_Framework_AssertionFailedError $e) {
         throw $e;
     } catch (\Exception $e) {
         // Correctly thrown exception
         $this->assertInstanceOf(\InvalidArgumentException::class, $e);
     }
     // Missing sender
     try {
         $sender->send(Sender::MODE_NONE);
         $this->fail(sprintf('Expected exception %s.', \Jyxo\Mail\Sender\CreateException::class));
     } catch (\PHPUnit_Framework_AssertionFailedError $e) {
         throw $e;
     } catch (\Exception $e) {
         // Correctly thrown exception
         $this->assertInstanceOf(\Jyxo\Mail\Sender\CreateException::class, $e);
     }
     $email->setFrom(new Email\Address('blog-noreply@blog.cz'));
     // Missing recipients
     try {
         $sender->send(Sender::MODE_NONE);
         $this->fail(sprintf('Expected exception %s.', \Jyxo\Mail\Sender\CreateException::class));
     } catch (\PHPUnit_Framework_AssertionFailedError $e) {
         throw $e;
     } catch (\Exception $e) {
         // Correctly thrown exception
         $this->assertInstanceOf(\Jyxo\Mail\Sender\CreateException::class, $e);
     }
     $email->addTo(new Email\Address('test@blog.cz'));
     // Empty body
     try {
         $sender->send(Sender::MODE_NONE);
         $this->fail(sprintf('Expected exception %s.', \Jyxo\Mail\Sender\CreateException::class));
     } catch (\PHPUnit_Framework_AssertionFailedError $e) {
         throw $e;
     } catch (\Exception $e) {
         // Correctly thrown exception
         $this->assertInstanceOf(\Jyxo\Mail\Sender\CreateException::class, $e);
     }
 }
開發者ID:jyxo,項目名稱:php,代碼行數:52,代碼來源:SenderTest.php

示例12: _write

 /**
  * Send an email to the email address set in
  * this writer.
  */
 public function _write($event)
 {
     // If no formatter set up, use the default
     if (!$this->_formatter) {
         $formatter = new SS_LogErrorEmailFormatter();
         $this->setFormatter($formatter);
     }
     $formattedData = $this->_formatter->format($event);
     $subject = $formattedData['subject'];
     $data = $formattedData['data'];
     $email = new Email();
     $email->setTo($this->emailAddress);
     $email->setSubject($subject);
     $email->setBody($data);
     $email->setFrom(self::$send_from);
     $email->send();
 }
開發者ID:helpfulrobot,項目名稱:azt3k-abc-silverstripe-mailer,代碼行數:21,代碼來源:SMTP_LogEmailWriter.php

示例13: Email

 /**
  * Email the welcome message and return to the view account page
  */
 function send_email()
 {
     // Construct an Email
     $email = new Email();
     $email->setFrom($this->conf['company']['email'], $this->conf['company']['name']);
     $email->addRecipient($this->session['welcome_email']['email']);
     $email->setSubject($this->session['welcome_email']['subject']);
     $email->setBody($this->session['welcome_email']['email_body']);
     // Send the email
     if (!$email->send()) {
         // Error delivering invoice
         throw new SWUserException("[WELCOME_EMAIL_FAILED]");
     }
     // Return to view_account with a sucess message
     $this->setMessage(array("type" => "[WELCOME_SENT]"));
     $this->gotoPage("accounts_view_account", null, "account=" . $this->get['account']->getID());
 }
開發者ID:carriercomm,項目名稱:NeoBill,代碼行數:20,代碼來源:WelcomeEmailPage.class.php

示例14: sendAjax

 function sendAjax()
 {
     $response = array();
     $comment = $this->input->post('comment');
     $email_address = $this->input->post('email');
     $name = $this->input->post('name');
     $type = $this->input->post('report_type');
     $message = $comment . "\n\n\n";
     foreach ($_SERVER as $k => $v) {
         $message .= $k . ': ' . $v . "\n";
     }
     require_once APPPATH . 'models/objects/email.php';
     $email = new Email();
     $email->setFrom($name . " <{$email_address}>");
     $email->setSubject('readbo.com - Reporting ' . $type . ' - ' . $name);
     $email->setBody($message);
     $response['success'] = $email->send('support@readbo.com');
     $this->sendToAjax($response);
 }
開發者ID:xtrimsky,項目名稱:readbo,代碼行數:19,代碼來源:reporting.php

示例15: execute

 public function execute(WorkflowInstance $workflow)
 {
     $email = new Email();
     $members = $workflow->getAssignedMembers();
     $emails = '';
     if (!$members || !count($members)) {
         return;
     }
     foreach ($members as $member) {
         if ($member->Email) {
             $emails .= "{$member->Email}, ";
         }
     }
     $context = $this->getContextFields($workflow->getTarget());
     $member = $this->getMemberFields();
     $variables = array();
     foreach ($context as $field => $val) {
         $variables["\$Context.{$field}"] = $val;
     }
     foreach ($member as $field => $val) {
         $variables["\$Member.{$field}"] = $val;
     }
     $subject = str_replace(array_keys($variables), array_values($variables), $this->EmailSubject);
     if ($this->ListingTemplateID) {
         $item = $workflow->customise(array('Items' => $workflow->Actions(), 'Member' => Member::currentUser(), 'Context' => $workflow->getTarget()));
         $template = DataObject::get_by_id('ListingTemplate', $this->ListingTemplateID);
         $view = SSViewer::fromString($template->ItemTemplate);
         $body = $view->process($item);
     } else {
         $body = str_replace(array_keys($variables), array_values($variables), $this->EmailTemplate);
     }
     $email->setSubject($subject);
     $email->setFrom($this->EmailFrom);
     $email->setBcc(substr($emails, 0, -2));
     $email->setBody($body);
     $email->send();
     return true;
 }
開發者ID:rodneyway,項目名稱:advancedworkflow,代碼行數:38,代碼來源:NotifyUsersWorkflowAction.php


注:本文中的Email::setBody方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。