예제 #1
0
 /**
  * Returns the full headers for the email properly encoded.
  *
  * @param   string $from The sender of the email
  * @param   string $to The recipient of the email
  * @param   string $subject The subject of this email
  * @return  string The full header version of the email
  */
 public function getFullHeaders($from, $to, $subject)
 {
     // encode the addresses
     $from = Mime_Helper::encodeAddress($from);
     $to = Mime_Helper::encodeAddress($to);
     $subject = Mime_Helper::encode($subject);
     $body = $this->mime->get(array('text_charset' => APP_CHARSET, 'head_charset' => APP_CHARSET, 'text_encoding' => APP_EMAIL_ENCODING));
     $this->setHeaders(array('From' => $from, 'To' => $to, 'Subject' => $subject));
     $hdrs = $this->mime->headers($this->headers);
     // RFC 822 formatted date
     $header = 'Date: ' . Date_Helper::getRFC822Date(time()) . "\r\n";
     // return the full dump of the email
     foreach ($hdrs as $name => $value) {
         $header .= "{$name}: {$value}\r\n";
     }
     $header .= "\r\n";
     return $header . $body;
 }