Hoa central
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Hoa\Mail\Content\Message Class Reference
Inheritance diagram for Hoa\Mail\Content\Message:

Public Member Functions

 __construct ()
 
 addContent (Content $content)
 
 getContent ()
 
 getRecipients ()
 
 getFormattedContent ($headers=false)
 
- Public Member Functions inherited from Hoa\Mail\Content\Content
 __construct ()
 
 offsetExists ($header)
 
 offsetGet ($header)
 
 offsetSet ($header, $value)
 
 offsetUnset ($header)
 
 getHeaders ()
 
 getFormattedContent ($headers=true)
 
 getId ()
 
 getIdUrl ()
 
 __toString ()
 

Public Attributes

const BOUNDARY = '@hoaproject-'
 

Protected Member Functions

 _getContent ()
 
 _getRecipients ($line, Array &$out)
 
- Protected Member Functions inherited from Hoa\Mail\Content\Content
 _getContent ()
 

Protected Attributes

 $_content = []
 
- Protected Attributes inherited from Hoa\Mail\Content\Content
 $_headers = []
 

Additional Inherited Members

- Static Public Member Functions inherited from Hoa\Mail\Content\Content
static formatHeaders (Array $headers)
 
static getAddress ($contact)
 
static getDomain ($contact)
 

Detailed Description

Class .

This class represents a message, that can also be a content of another message.

Definition at line 50 of file Message.php.

Constructor & Destructor Documentation

Hoa\Mail\Content\Message::__construct ( )

Constructor.

Returns
void

Definition at line 73 of file Message.php.

74  {
75  $this['content-type'] = 'multipart/mixed';
76  $this['date'] = date('r');
77 
78  return;
79  }

Member Function Documentation

Hoa\Mail\Content\Message::_getContent ( )
protected

Get final “plain” content.

Returns
string
Exceptions

Definition at line 110 of file Message.php.

111  {
112  $content = $this->getContent();
113 
114  if (empty($content)) {
115  throw new Mail\Exception('The message does not have content.', 0);
116  }
117 
118  if (1 < count($content)) {
119  $boundary =
120  '__bndry-' .
121  md5(static::BOUNDARY . microtime(true));
122  $frontier = '--' . $boundary;
123 
124  $this['content-type'] =
125  $this['content-type'] . '; ' .
126  'boundary="' . $boundary . '"';
127 
128  $message = static::formatHeaders($this->getHeaders()) . CRLF;
129 
130  foreach ($content as $c) {
131  $message .= $frontier . CRLF . $c . CRLF;
132  }
133 
134  $message .= $frontier . '--' . CRLF;
135  } else {
136  $oldContentType = $this['content-type'];
137  unset($this['content-type']);
138 
139  $message =
140  static::formatHeaders($this->getHeaders()) .
141  current($content);
142 
143  $this['content-type'] = $oldContentType;
144  }
145 
146  return $message;
147  }
$content
Definition: Hoa.php:119

Here is the call graph for this function:

Hoa\Mail\Content\Message::_getRecipients (   $line,
Array &  $out 
)
protected

Get recipients from a specific line (value of a header).

Parameters
string$lineLine.
array&$outOut.
Returns
void

Definition at line 179 of file Message.php.

180  {
181  $line = preg_replace_callback(
182  '#("|\')[^\1]+\1#',
183  function ($matches) {
184  return '';
185  },
186  $line
187  );
188 
189  foreach (explode(',', $line) as $contact) {
190  $out[] = static::getAddress($contact);
191  }
192 
193  return;
194  }

Here is the caller graph for this function:

Hoa\Mail\Content\Message::addContent ( Content  $content)

Add a content part.

Parameters
\Hoa\Mail\Content$contentContent part.
Returns

Definition at line 87 of file Message.php.

88  {
89  $this->_content[] = $content;
90 
91  return $this;
92  }
$content
Definition: Hoa.php:119

Here is the caller graph for this function:

Hoa\Mail\Content\Message::getContent ( )

Get content.

Returns
array

Definition at line 99 of file Message.php.

100  {
101  return $this->_content;
102  }

Here is the caller graph for this function:

Hoa\Mail\Content\Message::getFormattedContent (   $headers = false)

Override the parent::getFormattedContent method.

Parameters
bool$headersWith headers or not (forced to false here).
Returns
string

Definition at line 202 of file Message.php.

203  {
204  return parent::getFormattedContent(false);
205  }
Hoa\Mail\Content\Message::getRecipients ( )

Get all recipients of the message. The first recipient (index 0) is `$this['to']`.

Returns
array

Definition at line 155 of file Message.php.

156  {
157  $out = [];
158 
159  $this->_getRecipients($this['to'], $out);
160 
161  if (isset($this['cc'])) {
162  $this->_getRecipients($this['cc'], $out);
163  }
164 
165  if (isset($this['bcc'])) {
166  $this->_getRecipients($this['bcc'], $out);
167  }
168 
169  return $out;
170  }
_getRecipients($line, Array &$out)
Definition: Message.php:179

Here is the call graph for this function:

Member Data Documentation

Hoa\Mail\Content\Message::$_content = []
protected

Definition at line 64 of file Message.php.

const Hoa\Mail\Content\Message::BOUNDARY = '@hoaproject-'

Boundary hash prefix.

string

Definition at line 57 of file Message.php.


The documentation for this class was generated from the following file: