Namespaces

  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Config
      • Adapters
      • Extensions
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Diagnostics
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
      • PhpGenerator
  • NetteModule
  • None
  • PHP

Classes

  • Message
  • MimePart
  • SendmailMailer
  • SmtpMailer

Interfaces

  • IMailer

Exceptions

  • SmtpException
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the Nette Framework (http://nette.org)
 5:  *
 6:  * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
 7:  *
 8:  * For the full copyright and license information, please view
 9:  * the file license.txt that was distributed with this source code.
10:  */
11: 
12: namespace Nette\Mail;
13: 
14: use Nette;
15: 
16: 
17: 
18: /**
19:  * Sends emails via the PHP internal mail() function.
20:  *
21:  * @author     David Grudl
22:  */
23: class SendmailMailer extends Nette\Object implements IMailer
24: {
25:     /** @var string */
26:     public $commandArgs;
27: 
28: 
29: 
30:     /**
31:      * Sends email.
32:      * @return void
33:      */
34:     public function send(Message $mail)
35:     {
36:         $tmp = clone $mail;
37:         $tmp->setHeader('Subject', NULL);
38:         $tmp->setHeader('To', NULL);
39: 
40:         $parts = explode(Message::EOL . Message::EOL, $tmp->generateMessage(), 2);
41: 
42:         $args = array(
43:             str_replace(Message::EOL, PHP_EOL, $mail->getEncodedHeader('To')),
44:             str_replace(Message::EOL, PHP_EOL, $mail->getEncodedHeader('Subject')),
45:             str_replace(Message::EOL, PHP_EOL, $parts[1]),
46:             str_replace(Message::EOL, PHP_EOL, $parts[0]),
47:         );
48:         if ($this->commandArgs) {
49:             $args[] = (string) $this->commandArgs;
50:         }
51:         if (call_user_func_array('mail', $args) === FALSE) {
52:             $error = error_get_last();
53:             throw new Nette\InvalidStateException("Unable to send email: $error[message].");
54:         }
55:     }
56: 
57: }
58: 
Nette Framework 2.0.8 API API documentation generated by ApiGen 2.8.0