Packages

  • 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

  • NMail
  • NMailMimePart
  • NSendmailMailer
  • NSmtpMailer

Interfaces

  • IMailer

Exceptions

  • NSmtpException
  • Overview
  • Package
  • 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:  * @package Nette\Mail
11:  */
12: 
13: 
14: 
15: /**
16:  * Sends emails via the PHP internal mail() function.
17:  *
18:  * @author     David Grudl
19:  * @package Nette\Mail
20:  */
21: class NSendmailMailer extends NObject implements IMailer
22: {
23:     /** @var string */
24:     public $commandArgs;
25: 
26: 
27: 
28:     /**
29:      * Sends email.
30:      * @return void
31:      */
32:     public function send(NMail $mail)
33:     {
34:         $tmp = clone $mail;
35:         $tmp->setHeader('Subject', NULL);
36:         $tmp->setHeader('To', NULL);
37: 
38:         $parts = explode(NMail::EOL . NMail::EOL, $tmp->generateMessage(), 2);
39: 
40:         $args = array(
41:             str_replace(NMail::EOL, PHP_EOL, $mail->getEncodedHeader('To')),
42:             str_replace(NMail::EOL, PHP_EOL, $mail->getEncodedHeader('Subject')),
43:             str_replace(NMail::EOL, PHP_EOL, $parts[1]),
44:             str_replace(NMail::EOL, PHP_EOL, $parts[0]),
45:         );
46:         if ($this->commandArgs) {
47:             $args[] = (string) $this->commandArgs;
48:         }
49:         if (call_user_func_array('mail', $args) === FALSE) {
50:             $error = error_get_last();
51:             throw new InvalidStateException("Unable to send email: $error[message].");
52:         }
53:     }
54: 
55: }
56: 
Nette Framework 2.0.7 (for PHP 5.2, prefixed) API API documentation generated by ApiGen 2.8.0