|
1 <?php |
|
2 |
|
3 /* |
|
4 * This file is part of SwiftMailer. |
|
5 * (c) 2004-2009 Chris Corbyn |
|
6 * |
|
7 * For the full copyright and license information, please view the LICENSE |
|
8 * file that was distributed with this source code. |
|
9 */ |
|
10 |
|
11 |
|
12 /** |
|
13 * The Message class for building emails. |
|
14 * @package Swift |
|
15 * @subpackage Mime |
|
16 * @author Chris Corbyn |
|
17 */ |
|
18 class Swift_Message extends Swift_Mime_SimpleMessage |
|
19 { |
|
20 |
|
21 /** |
|
22 * Create a new Message. |
|
23 * Details may be optionally passed into the constructor. |
|
24 * @param string $subject |
|
25 * @param string $body |
|
26 * @param string $contentType |
|
27 * @param string $charset |
|
28 */ |
|
29 public function __construct($subject = null, $body = null, |
|
30 $contentType = null, $charset = null) |
|
31 { |
|
32 call_user_func_array( |
|
33 array($this, 'Swift_Mime_SimpleMessage::__construct'), |
|
34 Swift_DependencyContainer::getInstance() |
|
35 ->createDependenciesFor('mime.message') |
|
36 ); |
|
37 |
|
38 if (!isset($charset)) |
|
39 { |
|
40 $charset = Swift_DependencyContainer::getInstance() |
|
41 ->lookup('properties.charset'); |
|
42 } |
|
43 $this->setSubject($subject); |
|
44 $this->setBody($body); |
|
45 $this->setCharset($charset); |
|
46 if ($contentType) |
|
47 { |
|
48 $this->setContentType($contentType); |
|
49 } |
|
50 } |
|
51 |
|
52 /** |
|
53 * Create a new Message. |
|
54 * @param string $subject |
|
55 * @param string $body |
|
56 * @param string $contentType |
|
57 * @param string $charset |
|
58 * @return Swift_Mime_Message |
|
59 */ |
|
60 public static function newInstance($subject = null, $body = null, |
|
61 $contentType = null, $charset = null) |
|
62 { |
|
63 return new self($subject, $body, $contentType, $charset); |
|
64 } |
|
65 |
|
66 /** |
|
67 * Add a MimePart to this Message. |
|
68 * @param string|Swift_OutputByteStream $body |
|
69 * @param string $contentType |
|
70 * @param string $charset |
|
71 */ |
|
72 public function addPart($body, $contentType = null, $charset = null) |
|
73 { |
|
74 return $this->attach(Swift_MimePart::newInstance( |
|
75 $body, $contentType, $charset |
|
76 )); |
|
77 } |
|
78 |
|
79 public function __wakeup() |
|
80 { |
|
81 Swift_DependencyContainer::getInstance()->createDependenciesFor('mime.message'); |
|
82 } |
|
83 |
|
84 } |