本文整理汇总了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");
}
示例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();
}
示例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>";
}
示例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();
}
}
示例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' => '');
}
示例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' => '');
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
}
示例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();
}
示例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());
}
示例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);
}
示例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;
}