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


PHP Message::setFrom方法代碼示例

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


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

示例1: composeMail

 private function composeMail($from, $to, $subject)
 {
     $this->mail = new Message();
     $this->mail->setFrom($from)->setSubject($subject);
     $this->processFromEmail($from)->processToEmail($to);
     return $this->mail;
 }
開發者ID:xruff,項目名稱:apputils,代碼行數:7,代碼來源:Email.php

示例2: setFrom

 /**
  * @param string $email
  * @param string $name
  */
 public function setFrom($email, $name = null)
 {
     try {
         $this->message->setFrom($email, $name);
     } catch (\Exception $e) {
         throw new MailerException($e->getMessage());
     }
 }
開發者ID:rukzuk,項目名稱:rukzuk,代碼行數:12,代碼來源:Mailer.php

示例3: send

 /** Funkcia pre odoslanie emailu
  * @param array $params Parametre správy
  * @param string $subjekt Subjekt emailu
  * @return string Zoznam komu bol odoslany email
  * @throws SendException
  */
 public function send($params, $subjekt)
 {
     $templ = new Latte\Engine();
     $this->mail->setFrom($params["site_name"] . ' <' . $this->from . '>');
     $this->mail->setSubject($subjekt)->setHtmlBody($templ->renderToString($this->template, $params));
     try {
         $sendmail = new SendmailMailer();
         $sendmail->send($this->mail);
         return $this->email_list;
     } catch (Exception $e) {
         throw new SendException('Došlo k chybe pri odosielaní e-mailu. Skúste neskôr znovu...' . $e->getMessage());
     }
 }
開發者ID:petak23,項目名稱:echo-msz,代碼行數:19,代碼來源:Email.php

示例4: createMessage

 /**
  * Vytvoří novou zprávu jakožto objekt \Nette\Mail\Message.
  * @see \Nette\Mail\Message
  * @param string|array $to Příjemce zprávy. Víc příjemců může být předáno jako pole.
  * @param string $subject Předmět zprávy.
  * @param string $message Předmět zprávy, nastavuje se přes setHtmlBody, tudíž lze předat výstup šablony.
  */
 public function createMessage($to, $subject, $message)
 {
     $this->message = new \Nette\Mail\Message();
     $this->message->setFrom($this->from);
     if (is_array($to)) {
         foreach ($to as $recipient) {
             $this->message->addTo($recipient);
         }
     } else {
         $this->message->addTo($to);
     }
     $this->message->setSubject($subject);
     $this->message->setHtmlBody($message);
 }
開發者ID:JZechy,項目名稱:ZBox,代碼行數:21,代碼來源:Mailer.php

示例5: formSucceeded

 /**
  * Callback for ForgottenPasswordForm onSuccess event.
  * @param Form      $form
  * @param ArrayHash $values
  */
 public function formSucceeded(Form $form, $values)
 {
     $user = $this->userManager->findByEmail($values->email);
     if (!$user) {
         $form->addError('No user with given email found');
         return;
     }
     $password = Nette\Utils\Random::generate(10);
     $this->userManager->setNewPassword($user->id, $password);
     try {
         // !!! Never send passwords through email !!!
         // This is only for demonstration purposes of Notejam.
         // Ideally, you can create a unique link where user can change his password
         // himself for limited amount of time, and then send the link.
         $mail = new Nette\Mail\Message();
         $mail->setFrom('noreply@notejamapp.com', 'Notejamapp');
         $mail->addTo($user->email);
         $mail->setSubject('New notejam password');
         $mail->setBody(sprintf('Your new password: %s', $password));
         $this->mailer->send($mail);
     } catch (Nette\Mail\SendException $e) {
         Debugger::log($e, Debugger::EXCEPTION);
         $form->addError('Could not send email with new password');
     }
 }
開發者ID:martinmayer,項目名稱:notejam,代碼行數:30,代碼來源:ForgottenPasswordFormFactory.php

示例6: onFinish

 public function onFinish()
 {
     if (!count($this->messages)) {
         return;
     }
     // everything went alright
     $contents = implode(PHP_EOL, $this->messages) . PHP_EOL;
     // Only write the |$contents| to the file when this is not ran as part of a unit test.
     // Ideally we would verify that the write was successful, but there's no good fallback.
     if (!$this->isTest) {
         file_put_contents(self::ERROR_LOG, $contents, FILE_APPEND);
     }
     // Early-return if there are no failures, because there is no need to send an alert message
     // for successful service execution.
     if ($this->failures == 0) {
         return;
     }
     $configuration = Configuration::getInstance();
     // E-mail alerts can be disabled by the configuration, but force-enable them for tests.
     if (!$configuration->get('serviceLog/alerts') && !$this->isTest) {
         return;
     }
     // Compose an e-mail message for sending out an alert message. The recipients of this
     // message are defined in the main configuration file.
     $alert = new Message();
     $alert->setFrom($configuration->get('serviceLog/from'))->setSubject($configuration->get('serviceLog/subject'))->setBody($contents);
     foreach ($configuration->get('serviceLog/recipients') as $recipient) {
         $alert->addTo($recipient);
     }
     $this->mailer->send($alert);
 }
開發者ID:AnimeNL,項目名稱:anime-2016,代碼行數:31,代碼來源:ServiceLogImpl.php

示例7: sendMail

 public function sendMail($formValues)
 {
     //        dump($formValues);
     //        die();
     //
     $template = new Nette\Templating\FileTemplate(__DIR__ . '/emailTemplates/' . $this->templateFilename);
     $template->registerFilter(new Nette\Latte\Engine());
     $template->registerHelperLoader('Nette\\Templating\\Helpers::loader');
     $attachments = array();
     if (isset($formValues['cv']) && $formValues['cv'] instanceof Nette\Http\FileUpload) {
         if ($formValues['cv']->isOk()) {
             $attachments[$formValues['cv']->getName()] = $formValues['cv']->getContents();
         }
     }
     unset($formValues['cv']);
     $template->values = $formValues;
     //        echo $template;
     //        die();
     $mail = new \Nette\Mail\Message();
     $mail->setFrom($this->from)->setSubject($this->subject)->addTo($this->to)->setHtmlBody($template);
     if ($attachments) {
         foreach ($attachments as $name => $content) {
             $mail->addAttachment($name, $content);
         }
     }
     //        foreach ($tos as $to) {
     //            $mail->addTo($to);
     //        }
     $mail->send();
 }
開發者ID:jurasm2,項目名稱:bubo-sandbox,代碼行數:30,代碼來源:MailForm.php

示例8: prepareMessage

 /**
  *
  * @return Message 
  */
 private function prepareMessage()
 {
     $message = new Message();
     $message->setFrom($this->from, $this->fromName);
     $message->setMailer($this->mailer);
     return $message;
 }
開發者ID:bazo,項目名稱:translation-ui,代碼行數:11,代碼來源:MailBuilder.php

示例9: orderFormSucceeded

 function orderFormSucceeded(Form $form, $values)
 {
     $user = $this->findUser();
     $order = new Order($user);
     $order->setType($values->type);
     $order->setAmount($values->amount);
     $order->setName($values->name);
     $order->setPhone($values->phone);
     $order->setBusinessName($values->business_name);
     $order->setIc($values->ic);
     $order->setDic($values->dic);
     $order->setAddress($values->address);
     $order->setInvoiceAddress($values->invoice_address);
     $order->setShippingMethod($values->shipping_method);
     $order->setNote($values->note);
     $price_index = $values->type . '.price_per_unit';
     $order->setPricePerUnit(Settings::get($price_index));
     $this->em->persist($order);
     $this->em->flush();
     $order->createNum();
     $this->em->flush();
     $this->orderManager->invoice($order, true);
     $mail = new Message();
     $mail->setFrom(Settings::get('contact.name') . ' <' . Settings::get('contact.email') . '>')->addTo($order->getUser()->getEmail())->setSubject('Your order ' . $order->getNum())->setBody('You have placed a new order on kryo.mossbauer.cz. Please follow payment instructions in attachment.');
     $mail->addAttachment(WWW_DIR . '/../temp/' . $order->getInvoiceFileName());
     $this->mailer->send($mail);
     $this->flashMessage('Order has been successfully created!', 'success');
     $this->redirect('this');
 }
開發者ID:vitush93,項目名稱:kryo,代碼行數:29,代碼來源:HomepagePresenter.php

示例10: formSucceeded

 /**
  * Callback method, that is called once form is successfully submitted, without validation errors.
  *
  * @param Form $form
  * @param Nette\Utils\ArrayHash $values
  */
 public function formSucceeded(Form $form, $values)
 {
     if (!($user = $this->userRepository->findOneBy(['email' => $values->email]))) {
         $form['email']->addError("User with given email doesn't exist");
         return;
     }
     // this is not a very secure way of getting new password
     // but it's the same way the symfony app is doing it...
     $newPassword = $user->generateRandomPassword();
     $this->em->flush();
     try {
         $message = new Nette\Mail\Message();
         $message->setSubject('Notejam password');
         $message->setFrom('noreply@notejamapp.com');
         $message->addTo($user->getEmail());
         // !!! Never send passwords through email !!!
         // This is only for demonstration purposes of Notejam.
         // Ideally, you can create a unique link where user can change his password
         // himself for limited amount of time, and then send the link.
         $message->setBody("Your new password is {$newPassword}");
         $this->mailer->send($message);
     } catch (Nette\Mail\SendException $e) {
         Debugger::log($e, 'email');
         $form->addError('Could not send email with new password');
     }
     $this->onSuccess($this);
 }
開發者ID:martinmayer,項目名稱:notejam,代碼行數:33,代碼來源:ForgottenPasswordControl.php

示例11: send

 /**
  * @param string $senderEmail
  * @param string $recipientEmail
  * @param callable $templateCallback
  * @param array $param
  * @throws InvalidStateException
  */
 public function send($senderEmail, $recipientEmail, callable $templateCallback, array $param = [])
 {
     $template = $this->prepareTemplate($templateCallback, $param);
     $mail = new Message();
     $mail->setFrom($senderEmail)->addTo($recipientEmail)->setHtmlBody($template);
     $this->mailer->send($mail);
 }
開發者ID:blitzik,項目名稱:vycetky,代碼行數:14,代碼來源:EmailNotifier.php

示例12: buyFormSucceeded

 public function buyFormSucceeded(\CustomForm $form, $values)
 {
     $product = $this->context->moduleSimpleEshopModel->getProduct($this->getParameter("id"), 1);
     $this->iModuleId = $product["page_page_modules_id"];
     $this->loadModuleFromDB();
     if ($form->isValid()) {
         $values["product_id"] = $product["id"];
         $values["product_title"] = $product["title"];
         $values["page_page_modules_id"] = $product["page_page_modules_id"];
         $order = $this->db->createOrder($values);
         if (!$order) {
             $this->flashMessage('Jejda. :( Něco je špatně. Zkuste znovu nebo se s námi spojte přímo. Děkujeme za pochopení.');
         } else {
             $mail = new Message();
             $mailer = new SendmailMailer();
             $emailHTML = $this->getEmailHTML($order, $product);
             // send confirmation email to customer
             $mail->setFrom($this->module->settings->email)->addTo($order->email)->setSubject('Potvrzení o koupi.')->setHTMLBody($emailHTML);
             $mailer->send($mail);
             // send confirmation email to owner of the eshop
             $mail->setFrom($this->module->settings->email)->addTo($this->module->settings->email)->setSubject('Potvrzení o koupi.')->setHTMLBody($emailHTML);
             $mailer->send($mail);
             $this->flashMessage($this->module->settings->order_confirmation, 'success');
         }
     } else {
         $this->flashMessage('Doplňte prosím všechny povinné položky.');
     }
     $this->redirect(":" . $this->getName() . ':Product', array('id' => $product['nice_url_segment'], 'moduleid' => $product['page_page_modules_id']));
 }
開發者ID:petrparolek,項目名稱:web_cms,代碼行數:29,代碼來源:ModuleSimpleEshopPresenter.php

示例13: send

 /**
  * @param string $user
  * @param string $name
  * @param string $type
  * @param string $action
  * @param mixed[] $templateArgs
  */
 public function send($user, $name, $type, $action, array $templateArgs = array())
 {
     $presenter = $this->createPresenter();
     $request = $this->getRequest($type, $action);
     $response = $presenter->run($request);
     $presenter->template->user = $user;
     $presenter->template->name = $name;
     foreach ($templateArgs as $key => $val) {
         $presenter->template->{$key} = $val;
     }
     if (!$response instanceof TextResponse) {
         throw new InvalidArgumentException(sprintf('Type \'%s\' does not exist.', $type));
     }
     try {
         $data = (string) $response->getSource();
     } catch (\Nette\Application\BadRequestException $e) {
         if (Strings::startsWith($e->getMessage(), 'Page not found. Missing template')) {
             throw new InvalidArgumentException(sprintf('Type \'%s\' does not exist.', $type));
         }
     }
     $message = new Message();
     $message->setHtmlBody($data);
     $message->setSubject(ucfirst($action));
     $message->setFrom($this->senderEmail, $this->senderName ?: null);
     $message->addTo($user, $name);
     $this->mailer->send($message);
 }
開發者ID:venne,項目名稱:venne,代碼行數:34,代碼來源:EmailManager.php

示例14: send

 public function send($from, $to, $subject, $template)
 {
     $mail = new Message();
     $mail->setFrom($from)->addTo($to)->setSubject($subject)->setHTMLBody($template);
     $mailer = new SendmailMailer();
     $mailer->send($mail);
 }
開發者ID:jaromir92,項目名稱:Sportwin,代碼行數:7,代碼來源:MailSender.php

示例15: sendMailConsumer

 public function sendMailConsumer(\PhpAmqpLib\Message\AMQPMessage $message)
 {
     $sendMail = json_decode($message->body);
     $latte = new Latte\Engine();
     $sendMail->templateArr->email = $sendMail->to;
     $sendMail->templateArr->subject = $sendMail->subject;
     if (!is_null($sendMail->unsubscribeLink)) {
         $sendMail->templateArr->unsubscribeLink = $sendMail->unsubscribeLink;
     }
     $mail = new Nette\Mail\Message();
     $mail->setFrom($sendMail->from)->addTo($sendMail->to)->setHtmlBody($latte->renderToString($this->config["appDir"] . $this->config['mailer']['templateDir'] . (is_null($sendMail->template) ? $this->config['mailer']['defaultTemplate'] : $sendMail->template), (array) $sendMail->templateArr));
     if (!is_null($sendMail->unsubscribeEmail) || !is_null($sendMail->unsubscribeLink)) {
         $mail->setHeader('List-Unsubscribe', (!is_null($sendMail->unsubscribeEmail) ? '<mailto:' . $sendMail->unsubscribeEmail . '>' : '') . (!is_null($sendMail->unsubscribeEmail) && !is_null($sendMail->unsubscribeLink) ? ", " : "") . (!is_null($sendMail->unsubscribeLink) ? '<' . $sendMail->unsubscribeLink . '>' : ''), TRUE);
     }
     $mail->setSubject($sendMail->subject);
     try {
         $mailer = $this->emailFactory->getConnection($sendMail->connection);
         $mailer->send($mail);
         dump($sendMail->to);
         if ($sendMail->imapSave) {
             $this->saveToImap($mail->generateMessage(), is_null($sendMail->imapFolder) ? $this->config['imap']['sendFolder'] : $sendMail->imapFolder, $sendMail->imapConnection);
         }
         return TRUE;
     } catch (\Exception $e) {
         return FALSE;
     }
 }
開發者ID:trejjam,項目名稱:emailing,代碼行數:27,代碼來源:Mailer.php


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