38 public function __construct($recipient, array $whitelist = array())
40 $this->_recipient = $recipient;
41 $this->_whitelist = $whitelist;
51 $this->_recipient = $recipient;
71 $this->_whitelist = $whitelist;
92 $headers = $message->getHeaders();
96 if ($headers->has(
'to')) {
97 $headers->addMailboxHeader(
'X-Swift-To', $message->getTo());
100 if ($headers->has(
'cc')) {
101 $headers->addMailboxHeader(
'X-Swift-Cc', $message->getCc());
104 if ($headers->has(
'bcc')) {
105 $headers->addMailboxHeader(
'X-Swift-Bcc', $message->getBcc());
114 $to = $message->getTo();
119 foreach ((array) $this->_recipient as $recipient) {
120 if (!array_key_exists($recipient, $to)) {
121 $message->addTo($recipient);
134 foreach ($headerSet->
getAll($type) as $headers) {
150 foreach ($recipients as $address => $name) {
152 $filtered[$address] = $name;
168 if (in_array($recipient, (array) $this->_recipient)) {
172 foreach ($this->_whitelist as $pattern) {
173 if (preg_match($pattern, $recipient)) {
196 if ($headers->has(
'X-Swift-To')) {
197 $message->
setTo($headers->get(
'X-Swift-To')->getNameAddresses());
198 $headers->removeAll(
'X-Swift-To');
200 $message->
setTo(null);
203 if ($headers->has(
'X-Swift-Cc')) {
204 $message->
setCc($headers->get(
'X-Swift-Cc')->getNameAddresses());
205 $headers->removeAll(
'X-Swift-Cc');
208 if ($headers->has(
'X-Swift-Bcc')) {
209 $message->
setBcc($headers->get(
'X-Swift-Bcc')->getNameAddresses());
210 $headers->removeAll(
'X-Swift-Bcc');