I extended Zend_Mail in order to log all outgoing emails.

overriden

    public function send($transport = null) {
     // Send
     parent::send($transport);

     // Log
     $this->log();

     return $this;
}

private function log() {
 $log = new Zend_Log();
$log->addWriter(new Zend_Log_Writer_Stream(
realpath(APPLICATION_PATH . '/../data/logs') . '/email-' .
Zend_Date::now()->toString('YYYY-MM-dd') . '.log'
 ));

$tpl = '
From: %s
To: %s
Subject: %s
Message (txt): %s
Message (html): %s';

$log->info(sprintf(
$tpl,
 $this->getFrom(),
var_export($this->getRecipients(), true),
$this->getSubject(),
 $this->getBodyText()->getContent(),
$this->getBodyHtml()->getContent()
 ));
}

But message bodies are encoded, how can I get normal mail bodies inside
Zend_Mail class?

Regards,
Saša Stamenković

Reply via email to