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

  • Mail
  • MailMimePart
  • SendmailMailer
  • SmtpMailer

Interfaces

  • IMailer

Exceptions

  • SmtpException
  • Overview
  • Package
  • Class
  • Tree
 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 SendmailMailer extends Object implements IMailer
22: {
23:     /** @var string */
24:     public $commandArgs;
25: 
26: 
27: 
28:     /**
29:      * Sends email.
30:      * @param  Mail
31:      * @return void
32:      */
33:     public function send(Mail $mail)
34:     {
35:         $tmp = clone $mail;
36:         $tmp->setHeader('Subject', NULL);
37:         $tmp->setHeader('To', NULL);
38: 
39:         $parts = explode(Mail::EOL . Mail::EOL, $tmp->generateMessage(), 2);
40: 
41:         Debugger::tryError();
42:         $args = array(
43:             str_replace(Mail::EOL, PHP_EOL, $mail->getEncodedHeader('To')),
44:             str_replace(Mail::EOL, PHP_EOL, $mail->getEncodedHeader('Subject')),
45:             str_replace(Mail::EOL, PHP_EOL, $parts[1]),
46:             str_replace(Mail::EOL, PHP_EOL, $parts[0]),
47:         );
48:         if ($this->commandArgs) {
49:             $args[] = (string) $this->commandArgs;
50:         }
51:         $res = call_user_func_array('mail', $args);
52: 
53:         if (Debugger::catchError($e)) {
54:             throw new InvalidStateException('mail(): ' . $e->getMessage(), 0, $e);
55: 
56:         } elseif (!$res) {
57:             throw new InvalidStateException('Unable to send email.');
58:         }
59:     }
60: 
61: }
62: 
Nette Framework 2.0.5 (for PHP 5.2, un-prefixed) API API documentation generated by ApiGen 2.7.0