66 $this->_replacements = (array) $replacements;
70 $this->_replacements = $replacements;
83 $to = array_keys($message->getTo());
84 $address = array_shift($to);
87 $body = $message->getBody();
88 $search = array_keys($replacements);
89 $replace = array_values($replacements);
90 $bodyReplaced = str_replace(
91 $search, $replace, $body
93 if ($body != $bodyReplaced)
95 $this->_originalBody = $body;
96 $message->setBody($bodyReplaced);
98 $subject = $message->getSubject();
99 $subjectReplaced = str_replace(
100 $search, $replace, $subject
102 if ($subject != $subjectReplaced)
104 $this->_originalSubject = $subject;
105 $message->setSubject($subjectReplaced);
107 $children = (array) $message->getChildren();
108 foreach ($children as $child)
110 list(
$type, ) = sscanf($child->getContentType(),
'%[^/]/%s');
113 $body = $child->getBody();
114 $bodyReplaced = str_replace(
115 $search, $replace, $body
117 if ($body != $bodyReplaced)
119 $child->setBody($bodyReplaced);
120 $this->_originalChildBodies[$child->getId()] = $body;
124 $this->_lastMessage = $message;
146 return $this->_replacements->getReplacementsFor($address);
150 return isset($this->_replacements[$address])
151 ? $this->_replacements[$address]
172 if ($this->_lastMessage === $message)
174 if (isset($this->_originalBody))
176 $message->
setBody($this->_originalBody);
177 $this->_originalBody = null;
179 if (isset($this->_originalSubject))
181 $message->
setSubject($this->_originalSubject);
182 $this->_originalSubject = null;
184 if (!empty($this->_originalChildBodies))
187 foreach ($children as $child)
189 $id = $child->getId();
190 if (array_key_exists(
$id, $this->_originalChildBodies))
192 $child->setBody($this->_originalChildBodies[
$id]);
195 $this->_originalChildBodies = array();
197 $this->_lastMessage = null;