本文整理汇总了PHP中Email::setTo方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::setTo方法的具体用法?PHP Email::setTo怎么用?PHP Email::setTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Email
的用法示例。
在下文中一共展示了Email::setTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: 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;
}
示例3: 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
示例4: 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");
}
示例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: testSendingAnEmail
function testSendingAnEmail()
{
$email = new Email(self::getApplication());
$email->setSubject('test');
$email->setText('some text');
$email->setFrom('tester@integry.com', 'Unit Test');
$email->setTo('recipient@test.com', 'Recipient');
$res = $email->send();
$this->assertEqual($res, 1);
}
示例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: 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();
}
}
示例9: 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' => '');
}
示例10: 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' => '');
}
示例11: 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();
}
示例12: 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');
}
示例13: 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();
}
示例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: doJobForm
/**
* Adds or modifies a job on the website.
*
* @param array $data
* @param Form $form
*/
public function doJobForm()
{
$data = $this->request->postVars();
$form = new JobBoardForm($this);
$form->loadDataFrom($data);
$existed = false;
if (!isset($data['JobID']) && !$data['JobID']) {
$job = new Job();
} else {
$job = Job::get()->byId($data['JobID']);
$existed = true;
if ($job && !$job->canEdit()) {
return $this->owner->httpError(404);
} else {
$job = new Job();
}
}
$form->saveInto($job);
$job->isActive = true;
$job->write();
Session::set('JobID', $job->ID);
$member = Member::get()->filter(array('Email' => $data['Email']))->first();
if (!$member) {
$member = new Member();
$member->Email = $SQL_email;
$member->FirstName = isset($data['Company']) ? $data['Company'] : false;
$password = Member::create_new_password();
$member->Password = $password;
$member->write();
$member->addToGroupByCode('job-posters', _t('Jobboard.JOBPOSTERSGROUP', 'Job Posters'));
}
$member->logIn();
$job->MemberID = $member->ID;
$job->write();
if (!$existed) {
$email = new Email();
$email->setSubject($data['EmailSubject']);
$email->setFrom($data['EmailFrom']);
$email->setTo($member->Email);
// send the welcome email.
$email->setTemplate('JobPosting');
$email->populateTemplate(array('Member' => $member, 'Password' => isset($password) ? $password : false, 'FirstPost' => $password ? true : false, 'Holder' => $this, 'Job' => $job));
if ($notify = $form->getController()->getJobNotifyAddress()) {
$email->setBcc($notify);
}
$email->send();
}
return $this->redirect($data['BackURL']);
}
开发者ID:helpfulrobot,项目名称:fullscreeninteractive-silverstripe-jobboard,代码行数:55,代码来源:JobBoardFormProcessor.php