Namespaces

  • Latte
    • Loaders
    • Macros
    • Runtime
  • Nette
    • Application
      • Responses
      • Routers
      • UI
    • Bridges
      • ApplicationDI
      • ApplicationLatte
      • ApplicationTracy
      • CacheDI
      • CacheLatte
      • DatabaseDI
      • DatabaseTracy
      • DITracy
      • FormsDI
      • FormsLatte
      • Framework
      • HttpDI
      • HttpTracy
      • MailDI
      • ReflectionDI
      • SecurityDI
      • SecurityTracy
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Conventions
      • Drivers
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
    • Reflection
    • Security
    • Utils
  • none
  • Tracy
    • Bridges
      • Nette

Classes

  • Message
  • MimePart
  • SendmailMailer
  • SmtpMailer

Interfaces

  • IMailer

Exceptions

  • SendException
  • SmtpException
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Other releases
  • Nette homepage
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the Nette Framework (https://nette.org)
 5:  * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
 6:  */
 7: 
 8: namespace Nette\Mail;
 9: 
10: use Nette;
11: 
12: 
13: /**
14:  * Sends emails via the PHP internal mail() function.
15:  */
16: class SendmailMailer extends Nette\Object implements IMailer
17: {
18:     /** @var string */
19:     public $commandArgs;
20: 
21: 
22:     /**
23:      * Sends email.
24:      * @return void
25:      * @throws SendException
26:      */
27:     public function send(Message $mail)
28:     {
29:         $tmp = clone $mail;
30:         $tmp->setHeader('Subject', NULL);
31:         $tmp->setHeader('To', NULL);
32: 
33:         $parts = explode(Message::EOL . Message::EOL, $tmp->generateMessage(), 2);
34: 
35:         $args = array(
36:             str_replace(Message::EOL, PHP_EOL, $mail->getEncodedHeader('To')),
37:             str_replace(Message::EOL, PHP_EOL, $mail->getEncodedHeader('Subject')),
38:             str_replace(Message::EOL, PHP_EOL, $parts[1]),
39:             str_replace(Message::EOL, PHP_EOL, $parts[0]),
40:         );
41:         if ($this->commandArgs) {
42:             $args[] = (string) $this->commandArgs;
43:         }
44:         $res = Nette\Utils\Callback::invokeSafe('mail', $args, function ($message) use (& $info) {
45:             $info = ": $message";
46:         });
47:         if ($res === FALSE) {
48:             throw new SendException("Unable to send email$info.");
49:         }
50:     }
51: 
52: }
53: 
Nette 2.3-20161221 API API documentation generated by ApiGen 2.8.0