本文整理汇总了PHP中Email::setFrom方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::setFrom方法的具体用法?PHP Email::setFrom怎么用?PHP Email::setFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Email
的用法示例。
在下文中一共展示了Email::setFrom方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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
示例2: 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");
}
示例3: sendMessage
private function sendMessage(NewsletterSentMessage $sent, LiveCart $application)
{
$config = $application->getConfig();
$email = new Email($application);
$email->setTemplate('newsletter/template');
$email->set('subject', $this->subject->get());
$email->set('htmlMessage', $this->html->get());
$email->set('text', $this->text->get());
$email->set('email', $this->text->get());
$email->setFrom($config->get('NEWSLETTER_EMAIL') ? $config->get('NEWSLETTER_EMAIL') : $config->get('MAIN_EMAIL'), $config->get('STORE_NAME'));
if ($user = $sent->user->get()) {
$email->setTo($user->email->get(), $user->getName());
$email->set('email', $user->email->get());
} else {
if ($subscriber = $sent->subscriber->get()) {
$email->setTo($subscriber->email->get());
$email->set('email', $subscriber->email->get());
}
}
//$sent->time->set(new ARExpressionHandle('NOW()'));
$sent->save();
if ($this->status->get() == self::STATUS_NOT_SENT) {
$this->status->set(self::STATUS_PARTIALLY_SENT);
$this->time->set(new ARExpressionHandle('NOW()'));
$this->save();
}
return $email->send();
}
示例4: sendContactForm
public function sendContactForm($data, $form)
{
$email = new Email();
$email->setFrom('"mSupply Contact Form" <mSupply@mail.yakpost.org>')->setTo($this->SiteConfig()->ContactFormEmail)->setSubject('mSupply Message')->setTemplate('ContactFormEmail')->populateTemplate(new ArrayData(array('FullName' => $data['FullName'], 'Phone' => $data['Phone'], 'Email' => $data['Email'], 'Message' => $data['Message'])));
$email->send();
return $this->redirectback();
}
示例5: 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();
}
示例6: SendNewsletterForm
public function SendNewsletterForm($data, $form)
{
$email = new Email();
$email->setFrom('"mSupply Newsletter Form" <mSupply@mail.yakpost.org>')->setTo($this->SiteConfig()->NewsletterFormEmail)->setSubject('mSupply Newsletter Request')->setTemplate('NewsletterSignUpEmail')->populateTemplate(new ArrayData(array('Email' => $data['Email'])));
$email->send();
return $this->redirectback();
}
示例7: 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>";
}
示例8: emailCustomer
/**
* Sends an email receipt to customer
*
* @param CustomerOrder $order
* @return bool
* @todo Make subject configurable
* @todo Make tempalte more generic
*/
public function emailCustomer($order)
{
$subject = 'Thank you for order on ' . date('Y-m-d' . '!') . ' from website';
$from = SS_SEND_EMAIL_FROM;
$to = $this->Email;
$email = new Email();
$email->setFrom($from)->setTo($to)->setSubject($subject)->setTemplate('CustomerEmail')->populateTemplate(new ArrayData(array('Customer' => $order->Customer(), 'CartItems' => $order->OrderItems(), 'ShippingCostTotal' => $order->shippingcost(), 'CartTotal' => $order->TotalAmount)));
// $email->populateTemplate($order);
$email->send();
}
示例9: 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();
}
}
示例10: 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' => '');
}
示例11: 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' => '');
}
示例12: 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();
}
示例13: send
public function send()
{
if (!$this->buildValidator()->isValid()) {
return new ActionRedirectResponse('contactForm', 'index');
}
$email = new Email($this->application);
$email->setTemplate('contactForm/contactForm');
$email->setFrom($this->request->get('email'), $this->request->get('name'));
$email->setTo($this->config->get('NOTIFICATION_EMAIL'), $this->config->get('STORE_NAME'));
$email->set('message', $this->request->get('msg'));
$email->send();
return new ActionRedirectResponse('contactForm', 'sent');
}
示例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();
}