/** * Encodes an email message before sending * @param AEmail $email the email being sent * @return string the encoded message */ protected function encodeMessage(AEmail $email) { $encoded = array(); $encoded[] = "--" . $email->uniqueId; $encoded[] = "Content-Type: " . ($email->isHtml ? "text/html" : "text/plain") . "; charset=" . Yii::app()->charset; $encoded[] = "Content-Transfer-Encoding: base64"; $encoded = implode("\r\n", $encoded) . "\r\n\r\n"; $encoded .= chunk_split(base64_encode($email->render())); return $encoded; }