Hoa central
Sendmail.php
Go to the documentation of this file.
1 <?php
2 
37 namespace Hoa\Mail\Transport;
38 
39 use Hoa\Mail;
40 
50 class Sendmail implements ITransport\Out
51 {
57  protected $_parameters = null;
58 
59 
60 
68  public function __construct(Array $parameters = [])
69  {
70  $this->_parameters = $parameters;
71 
72  return;
73  }
74 
81  protected function setParameters(Array $parameters)
82  {
83  $old = $this->_parameters;
84  $this->_parameters = $parameters;
85 
86  return $old;
87  }
88 
94  public function getParameters()
95  {
96  return $this->_parameters;
97  }
98 
105  public function send(Mail\Message $message)
106  {
107  $content = $message->getFormattedContent();
108  $headers = $message->getHeaders();
109  $pos = strpos($content, CRLF . CRLF);
110  $_headers = substr($content, 0, $pos);
111  $_body = substr($content, $pos + 4);
112 
113  return mail(
114  $headers['to'],
115  $headers['subject'],
116  $_body,
117  $_headers,
118  $message->formatHeaders($this->getParameters())
119  );
120  }
121 }
setParameters(Array $parameters)
Definition: Sendmail.php:81
$content
Definition: Hoa.php:119
send(Mail\Message $message)
Definition: Sendmail.php:105
__construct(Array $parameters=[])
Definition: Sendmail.php:68