Hoa central
Message.php
Go to the documentation of this file.
1 <?php
2 
37 namespace Hoa\Mail;
38 
47 class Message extends Content\Message
48 {
54  const MIME_VERSION = '1.0';
55 
61  protected static $_defaultTransport = null;
62 
68  protected $_transport = null;
69 
70 
71 
72 
78  public function __construct()
79  {
80  parent::__construct();
81  $this['mime-version'] = static::MIME_VERSION;
82 
83  return;
84  }
85 
92  public static function setDefaultTransport(Transport\ITransport\Out $transport)
93  {
94  $old = static::$_defaultTransport;
95  static::$_defaultTransport = $transport;
96 
97  return $old;
98  }
99 
105  public static function getDefaultTransport()
106  {
107  return static::$_defaultTransport;
108  }
109 
116  public function setTransport(Transport\ITransport\Out $transport)
117  {
118  $old = $this->_transport;
119  $this->_transport = $transport;
120 
121  return $old;
122  }
123 
129  public function getTransport()
130  {
131  return $this->_transport ?: static::getDefaultTransport();
132  }
133 
140  public function send()
141  {
142  $transport = $this->getTransport();
143 
144  if (null === $transport) {
145  throw new Exception(
146  'Cannot send a message without specifying a transport.',
147  0
148  );
149  }
150 
151  return $transport->send($this);
152  }
153 }
static setDefaultTransport(Transport\ITransport\Out $transport)
Definition: Message.php:92
static getDefaultTransport()
Definition: Message.php:105
static $_defaultTransport
Definition: Message.php:61
const MIME_VERSION
Definition: Message.php:54
setTransport(Transport\ITransport\Out $transport)
Definition: Message.php:116