本文整理汇总了PHP中Nette\Mail\Message::setHtmlBody方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::setHtmlBody方法的具体用法?PHP Message::setHtmlBody怎么用?PHP Message::setHtmlBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Mail\Message
的用法示例。
在下文中一共展示了Message::setHtmlBody方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* Send message
*/
public function send()
{
if ($this->template instanceof ITemplate) {
$this->message->setHtmlBody((string) $this->template);
}
$this->mailer->send($this->message);
}
示例2: 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);
}
示例3: 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);
}
示例4: setHtmlBody
/**
* @param string $html
*/
public function setHtmlBody($html)
{
try {
$this->message->setHtmlBody($html, false);
} catch (\Exception $e) {
throw new MailerException($e->getMessage());
}
}
示例5: sendRegistrace
/**
* Funkce odesílající email s heslem po registraci.
*
* Maily odesílá podle šablony v presenters/Emaily/novyucet.latte
*
* @param string $jmeno Jméno člověka
* @param string $heslo Heslo
* @param string $email Email
* @return integer Počet odeslaných mailů
*/
public function sendRegistrace($jmeno, $heslo, $email)
{
$mail = new Message();
$mail->setFrom($this->mailerFromAddress)->setSubject('Registrace na stránkách SVJ Čiklova 647/3');
$mail->addTo($email, $jmeno);
$latte = new \Latte\Engine();
$params = array('email' => $email, 'heslo' => $heslo);
$mail->setHtmlBody($latte->renderToString(self::templateFolder . 'novyucet.latte', $params));
$this->mailer->send($mail);
return 1;
}
示例6: processForm
/**
* @param UI\Form $form
*/
public function processForm(UI\Form $form)
{
$values = $form->getValues();
$template = $this->createTemplate();
$mail = new Message();
$template->setFile(__DIR__ . '/../presenters/templates/Emails/contactForm.latte');
$mail->addTo($this->settings['adminMail'])->setFrom($values['email']);
$template->title = 'Zpráva z kontaktního formuláře';
$template->values = $values;
$mail->setHtmlBody($template);
$this->mailer->send($mail);
$this->flashMessage('Zpráva byla odeslána');
$this->presenter->redirect('Pages:view', ['id' => $this->settings['thanksPage']]);
}
示例7: send
/**
* @param Message $mail
* @param string $body
* @param array|NULL $params
*/
public function send(Message $mail, $body = NULL, array $params = NULL)
{
if ($body) {
$latte = $this->latteFactory->create();
$latte->setLoader(new StringLoader());
$latte->addProvider('uiControl', $this->linkGenerator);
UIMacros::install($latte->getCompiler());
$params = (array) $params;
// can be NULL
$html = $latte->renderToString($body, $params);
$mail->setHtmlBody($html);
}
$this->mailer->send($mail);
}
示例8: sendMail
private function sendMail($values)
{
$mail = new Message();
$mail->setSubject('Nová zpráva z kontaktního formuláře');
$mail->setFrom($values['email'], $values['name']);
$mail->addTo('feedback@zlomky-hrave.cz', 'Feedback form');
$template = $this->createTemplate();
$template->setFile(__DIR__ . '/templates/Mail.phtml');
$template->name = $values['name'];
$template->email = $values['email'];
$template->text = $values['text'];
$mail->setHtmlBody($template);
$mailer = new SendmailMailer();
$mailer->send($mail);
}
示例9: processContactForm
/**
* Process contact form, send message
* @param Form
*/
public function processContactForm(Form $form)
{
$values = $form->getValues(TRUE);
$mail = new Message();
$mail->setFrom($values['email'])->addTo('patrik.zizka.s@gmail.com')->setSubject('Zpráva z kontaktního formuláře');
$template = $this->createTemplate();
$template->setFile(__DIR__ . '/templates/mail/emailTemplate.latte');
$template->title = 'Zpráva z kontaktního formuláře';
$template->values = $values;
$mail->setHtmlBody($template);
$mailer = new SendmailMailer();
$mailer->send($mail);
$this->flashMessage('Zpráva byla úspěšně odeslána', 'alert-success');
$this->redirect('this');
}
示例10: 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);
}
}
示例11: prepareMailMessage
/**
* @param $templateName
* @param array $params=[]
* @return Message
*/
private function prepareMailMessage($templateName, $params = [])
{
//připravení šablony a naplnění parametry
$template = $this->createTemplate();
//připravení mailu
$mailMessage = new Message();
$template->setFile(__DIR__ . '/mail' . $templateName . '.latte');
if (!empty($params)) {
foreach ($params as $paramName => $param) {
$template->{$paramName} = $param;
}
}
$template->mail = $mailMessage;
$mailMessage->setFrom($this->mailFrom);
$mailMessage->setHtmlBody($template);
return $mailMessage;
}
示例12: send
/**
* Render latte template to string and send (and/or log) mail
* @return void
*/
public function send()
{
/**
* Set template variables
*/
$this->setTemplateVariables();
/**
* Set body/html body
*/
try {
$this->template->setFile($this->getTemplateFile());
if (version_compare(Latte\Engine::VERSION, '2.4.0', '>=')) {
$this->template->getLatte()->addProvider('uiControl', $this->linkGenerator);
} else {
$this->template->_control = $this->linkGenerator;
}
$this->message->setHtmlBody((string) $this->template, $this->mail_images_base_path);
} catch (MailingException $e) {
/**
* If mail template was set and not found, bubble exception up
*/
if ($this->template_file) {
throw $e;
}
/**
* Otherwise just suppose that user has set message body via ::setBody
*/
}
/**
* In case mail sending in on, send message
*/
if ($this->config === self::CONFIG_BOTH || $this->config === self::CONFIG_SEND) {
$this->mailer->send($this->message);
}
/**
* In case mail logging is turned on, log message
*/
if ($this->config === self::CONFIG_LOG || $this->config === self::CONFIG_BOTH) {
$this->logger->log($this->log_type, $this->message);
}
}
示例13: toMessage
/**
* @param array $templateParameters
* @return Nette\Mail\Message
*/
public function toMessage($templateParameters = [])
{
$latte = $this->latteFactory instanceof Nette\Bridges\ApplicationLatte\ILatteFactory ? $this->latteFactory->create() : new Latte\Engine();
$latte->setLoader(new Latte\Loaders\StringLoader());
$htmlBody = $latte->renderToString($this->template, $templateParameters);
$mail = new Nette\Mail\Message();
$mail->setFrom($this->from);
$mail->setSubject($this->subject);
$mail->setHtmlBody($htmlBody);
if ($this->cc !== NULL) {
foreach ($this->cc as $cc) {
$mail->addCc($cc);
}
}
if ($this->bcc !== NULL) {
foreach ($this->bcc as $bcc) {
$mail->addBcc($bcc);
}
}
return $mail;
}
示例14: mailNotify
/**
* Notify an humean on email
*
* @param $subject
* @param $message
* @param array $data
*/
public function mailNotify($subject, $message, $data = array())
{
$table = "<table>\n";
foreach ($data as $key => $value) {
try {
$value = (string) $value;
} catch (\Exception $e) {
$value = "<i>hodnota není text</i>";
}
$table .= "<tr><th>{$key}</th><td>{$value}</td></tr>\n";
}
$table .= "</table>\n";
$message = "<p>{$message}</p>\n\n";
if (count($data)) {
$message .= "<p>Tabulka dat:</p>\n{$table}";
}
$mail = new Nette\Mail\Message();
$mail->setSubject($subject);
$mail->setHtmlBody($message);
$mail->addTo(self::NOTIFY_EMAIL_ADDRESS);
$mailer = new Nette\Mail\SendmailMailer();
$mailer->send($mail);
}
示例15: send
/**
* Render latte template to string and send (and/or log) mail
* @return void
*/
public function send()
{
/**
* Set template variables
*/
$this->setTemplateVariables();
/**
* Set body/html body
*/
try {
$this->template->setFile($this->getTemplateFile());
$this->message->setHtmlBody((string) $this->template, $this->mail_images_base_path);
} catch (MailException $e) {
/**
* If mail template was set and not found, bubble exception up
*/
if ($this->template_file) {
throw $e;
}
/**
* Otherwise just suppose that user has set message body via ::setBody
*/
}
/**
* In case mail sending in on, send message
*/
if ($this->config === self::CONFIG_BOTH || $this->config === self::CONFIG_SEND) {
$this->mailer->send($this->message);
}
/**
* In case mail logging is turned on, log message
*/
if ($this->config === self::CONFIG_LOG || $this->config === self::CONFIG_BOTH) {
$this->logger->log($this->log_type, $this->message);
}
}