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:      * Sends email.
29:      * @return void
30:      */
31:     public function send(NMail $mail)
32:     {
33:         $tmp = clone $mail;
34:         $tmp->setHeader('Subject', NULL);
35:         $tmp->setHeader('To', NULL);
36: 
37:         $parts = explode(NMail::EOL . NMail::EOL, $tmp->generateMessage(), 2);
38: 
39:         $args = array(
40:             str_replace(NMail::EOL, PHP_EOL, $mail->getEncodedHeader('To')),
41:             str_replace(NMail::EOL, PHP_EOL, $mail->getEncodedHeader('Subject')),
42:             str_replace(NMail::EOL, PHP_EOL, $parts[1]),
43:             str_replace(NMail::EOL, PHP_EOL, $parts[0]),
44:         );
45:         if ($this->commandArgs) {
46:             $args[] = (string) $this->commandArgs;
47:         }
48:         if (call_user_func_array('mail', $args) === FALSE) {
49:             $error = error_get_last();
50:             throw new InvalidStateException("Unable to send email: $error[message].");
51:         }
52:     }
53: 
54: }
55: 
Nette Framework 2.0.11 (for PHP 5.2, prefixed) API API documentation generated by ApiGen 2.8.0