Merge branch 'maint/7.0'
[ninja.git] / application / vendor / swiftmailer / classes / Swift / Message.php
blobe8183ea54f4f3f58594ae13439cd1f46bc60091f
1 <?php
3 /*
4 * This file is part of SwiftMailer.
5 * (c) 2004-2009 Chris Corbyn
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
11 //@require 'Swift/Mime/SimpleMessage.php';
12 //@require 'Swift/MimePart.php';
13 //@require 'Swift/DependencyContainer.php';
15 /**
16 * The Message class for building emails.
17 * @package Swift
18 * @subpackage Mime
19 * @author Chris Corbyn
21 class Swift_Message extends Swift_Mime_SimpleMessage
24 /**
25 * Create a new Message.
26 * Details may be optionally passed into the constructor.
27 * @param string $subject
28 * @param string $body
29 * @param string $contentType
30 * @param string $charset
32 public function __construct($subject = null, $body = null,
33 $contentType = null, $charset = null)
35 call_user_func_array(
36 array($this, 'Swift_Mime_SimpleMessage::__construct'),
37 Swift_DependencyContainer::getInstance()
38 ->createDependenciesFor('mime.message')
41 if (!isset($charset))
43 $charset = Swift_DependencyContainer::getInstance()
44 ->lookup('properties.charset');
46 $this->setSubject($subject);
47 $this->setBody($body);
48 $this->setCharset($charset);
49 if ($contentType)
51 $this->setContentType($contentType);
55 /**
56 * Create a new Message.
57 * @param string $subject
58 * @param string $body
59 * @param string $contentType
60 * @param string $charset
61 * @return Swift_Mime_Message
63 public static function newInstance($subject = null, $body = null,
64 $contentType = null, $charset = null)
66 return new self($subject, $body, $contentType, $charset);
69 /**
70 * Add a MimePart to this Message.
71 * @param string|Swift_OutputByteStream $body
72 * @param string $contentType
73 * @param string $charset
75 public function addPart($body, $contentType = null, $charset = null)
77 return $this->attach(Swift_MimePart::newInstance(
78 $body, $contentType, $charset
79 ));