fromAddress = $fromAddress; $this->toAddress = $toAddress; $this->host = $host; $this->env = $env; } public function buildMessage($content, array $records) { $message = new \Swift_Message(); // Do any dynamic processing right here create Swift_Message given $content and $records $message ->setTo($this->toAddress) ->setFrom($this->fromAddress) ->setSubject($this->buildSubject()) ->setContentType('text/html') ; return $message; } private function buildSubject() { return sprintf('[%s][%s] Error Occurred', $this->host, $this->env); } }