PageRenderTime 62ms CodeModel.GetById 29ms RepoModel.GetById 1ms app.codeStats 0ms

/framework/vendor/swift/lib/classes/Swift/Message.php

http://zoop.googlecode.com/
PHP | 82 lines | 36 code | 8 blank | 38 comment | 2 complexity | e6a53077014c533578cea56587fd40ee MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1
  1. <?php
  2. /*
  3. * This file is part of SwiftMailer.
  4. * (c) 2004-2009 Chris Corbyn
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. //@require 'Swift/Mime/SimpleMessage.php';
  10. //@require 'Swift/MimePart.php';
  11. //@require 'Swift/DependencyContainer.php';
  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. * Create a new Message.
  22. * Details may be optionally passed into the constructor.
  23. * @param string $subject
  24. * @param string $body
  25. * @param string $contentType
  26. * @param string $charset
  27. */
  28. public function __construct($subject = null, $body = null,
  29. $contentType = null, $charset = null)
  30. {
  31. call_user_func_array(
  32. array($this, 'Swift_Mime_SimpleMessage::__construct'),
  33. Swift_DependencyContainer::getInstance()
  34. ->createDependenciesFor('mime.message')
  35. );
  36. if (!isset($charset))
  37. {
  38. $charset = Swift_DependencyContainer::getInstance()
  39. ->lookup('properties.charset');
  40. }
  41. $this->setSubject($subject);
  42. $this->setBody($body);
  43. $this->setCharset($charset);
  44. if ($contentType)
  45. {
  46. $this->setContentType($contentType);
  47. }
  48. }
  49. /**
  50. * Create a new Message.
  51. * @param string $subject
  52. * @param string $body
  53. * @param string $contentType
  54. * @param string $charset
  55. * @return Swift_Mime_Message
  56. */
  57. public static function newInstance($subject = null, $body = null,
  58. $contentType = null, $charset = null)
  59. {
  60. return new self($subject, $body, $contentType, $charset);
  61. }
  62. /**
  63. * Add a MimePart to this Message.
  64. * @param string|Swift_OutputByteStream $body
  65. * @param string $contentType
  66. * @param string $charset
  67. */
  68. public function addPart($body, $contentType = null, $charset = null)
  69. {
  70. return $this->attach(Swift_MimePart::newInstance(
  71. $body, $contentType, $charset
  72. ));
  73. }
  74. }