当前位置: 首页>>代码示例>>PHP>>正文


PHP Message::setBody方法代码示例

本文整理汇总了PHP中Nette\Mail\Message::setBody方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::setBody方法的具体用法?PHP Message::setBody怎么用?PHP Message::setBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nette\Mail\Message的用法示例。


在下文中一共展示了Message::setBody方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: 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

示例3: setBody

 /**
  * @param string $body
  */
 public function setBody($body)
 {
     try {
         $this->message->setBody($body);
     } catch (\Exception $e) {
         throw new MailerException($e->getMessage());
     }
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:11,代码来源:Mailer.php

示例4: generateMessage

 public function generateMessage(Reciever $reciever, ContentConfig $contentConfig)
 {
     $message = new Message();
     $message->setFrom($this->sender->getEmail(), $this->sender->getName());
     $message->setBody($contentConfig->getContent($reciever));
     $message->setSubject($contentConfig->getSubject());
     $message->addTo($reciever->getEmail(), $reciever->getFullName());
     $message->addBcc($this->sender->getEmail());
     foreach ($contentConfig->getAttachments() as $attachment) {
         $message->addAttachment($attachment);
     }
     return $message;
 }
开发者ID:cinno,项目名称:massmailer-1,代码行数:13,代码来源:ContentPreparer.php

示例5: bindMessage

 public function bindMessage(Mail\Message $message, array $data = [], $assetsDir = NULL)
 {
     if ($this->plain) {
         if ($this->plain instanceof UI\ITemplate) {
             $this->bindNetteTemplate($this->plain, $data);
         }
         $message->setBody($this->plain);
     }
     if ($this->html) {
         if ($this->html instanceof UI\ITemplate) {
             $this->bindNetteTemplate($this->html, $data);
         }
         $message->setHtmlBody($this->html, $assetsDir);
     }
 }
开发者ID:h4kuna,项目名称:mail-manager,代码行数:15,代码来源:Layout.php

示例6: sendMail

 /**
  * Handle message delivery.
  *
  * @return bool
  */
 public static function sendMail()
 {
     // Allow support for legacy argument style or new style.
     $args = func_get_args();
     if (func_num_args() == 1) {
         $options = $args[0];
     } else {
         $options = array_merge(array('to' => $args[0], 'subject' => $args[1], 'message' => $args[2], 'reply_to' => $args[3], 'delivery_date' => $args[4]), $args[5]);
     }
     $di = \Phalcon\Di::getDefault();
     $config = $di->get('config');
     $mail_config = $config->application->mail->toArray();
     // Do not deliver mail on development environments.
     if (DF_APPLICATION_ENV == "development" && !defined('DF_FORCE_EMAIL')) {
         $email_to = $mail_config['from_addr'];
         if (!empty($email_to)) {
             $options['to'] = $email_to;
         } else {
             return false;
         }
     }
     if (isset($mail_config['use_smtp']) && $mail_config['use_smtp']) {
         $smtp_config = $config->apis->smtp->toArray();
         $smtp_config['host'] = $smtp_config['server'];
         unset($smtp_config['server']);
         $transport = new SmtpMailer($smtp_config);
     } else {
         $transport = new SendmailMailer();
     }
     if (!is_array($options['to'])) {
         $options['to'] = array($options['to']);
     } else {
         $options['to'] = array_unique($options['to']);
     }
     foreach ((array) $options['to'] as $mail_to_addr) {
         if (empty($mail_to_addr)) {
             continue;
         }
         $mail_to_addr = str_replace('mailto:', '', $mail_to_addr);
         $mail = new Message();
         $mail->setSubject($options['subject']);
         $from_addr = isset($options['from']) ? $options['from'] : $mail_config['from_addr'];
         $from_name = isset($options['from_name']) ? $options['from_name'] : $mail_config['from_name'];
         $mail->setFrom($from_addr, $from_name);
         if (isset($mail_config['bounce_addr'])) {
             $mail->setReturnPath($mail_config['bounce_addr']);
         }
         /*
         // Include a specific "Direct replies to" header if specified.
         if ($options['reply_to'] && $validator->isValid($options['reply_to']))
             $mail->setReplyTo($options['reply_to']);
         else if (isset($mail_config['reply_to']) && $mail_config['reply_to'])
             $mail->setReplyTo($mail_config['reply_to']);
         */
         // Change the type of the e-mail's body if specified in the options.
         if (isset($options['text_only']) && $options['text_only']) {
             $mail->setBody(strip_tags($options['message']));
         } else {
             $mail->setHtmlBody($options['message'], false);
         }
         // Add attachment if specified in options.
         if (isset($options['attachments'])) {
             foreach ((array) $options['attachments'] as $attachment) {
                 $mail->addAttachment($attachment);
             }
         }
         /*
         // Modify the mail type if specified.
         if (isset($options['type']))
             $mail->setType($options['type']);
         */
         // Catch invalid e-mails.
         try {
             $mail->addTo($mail_to_addr);
         } catch (\Nette\Utils\AssertionException $e) {
             continue;
         }
         $transport->send($mail);
     }
     return true;
 }
开发者ID:Lavoaster,项目名称:PVLive,代码行数:86,代码来源:Messenger.php

示例7: sendEmail

 /**
  * Here's the magic
  *
  * @param array $recipients
  * @param null $subject
  * @param array $data
  * @throws EmailException
  */
 private function sendEmail($recipients = array(), $subject = '', $data)
 {
     // recipients check
     if (!is_array($recipients)) {
         $recipients = array($recipients);
     }
     if (count($recipients) < 1) {
         throw new EmailException('No subscribers provided. (possibly none in your system)');
     }
     // try sending e-mail
     try {
         $mail = new \Nette\Mail\Message();
         $mail->setFrom($this->senderEmail, $this->senderName)->setSubject($subject);
         foreach ($recipients as $recipient) {
             $mail->addBcc($recipient);
         }
         // set HTML / or plaintext body
         if ($this->htmlEmail == TRUE) {
             $mail->setHTMLBody($this->getEmailTemplate($data));
         } else {
             $mail->setBody($this->getEmailTemplate($data));
         }
         $this->mailer->send($mail);
     } catch (\Exception $e) {
         throw new EmailException($e->getMessage());
     }
 }
开发者ID:ntamvl,项目名称:planningelegance,代码行数:35,代码来源:Email.php

示例8: sendTestEmailSmtp

 public function sendTestEmailSmtp($from, $to, $settings)
 {
     $mailer = new SmtpMailer($settings);
     $message = new Message();
     $message->setFrom($from);
     $message->addTo($to);
     $message->setBody('Tatami mail test');
     $message->setMailer($mailer);
     $message->send();
 }
开发者ID:bazo,项目名称:Tatami,代码行数:10,代码来源:Installer.php


注:本文中的Nette\Mail\Message::setBody方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。