setHeaderEncoding() public méthode

Set the encoding of mail headers
public setHeaderEncoding ( string $encoding ) : Zend_Mail
$encoding string Zend_Mime::ENCODING_QUOTEDPRINTABLE or Zend_Mime::ENCODING_BASE64
Résultat Zend_Mail Provides fluent interface
 public static function execute($subject, $to, $from, $body)
 {
     sfOpenPNEApplicationConfiguration::registerZend();
     $subject = mb_convert_kana($subject, 'KV');
     $mailer = new Zend_Mail('iso-2022-jp');
     $mailer->setHeaderEncoding(Zend_Mime::ENCODING_BASE64)->setFrom($from)->addTo($to)->setSubject(mb_encode_mimeheader($subject, 'iso-2022-jp'))->setBodyText(mb_convert_encoding($body, 'JIS', 'UTF-8'), 'iso-2022-jp', Zend_Mime::ENCODING_7BIT);
     $result = $mailer->send();
     Zend_Loader::registerAutoLoad('Zend_Loader', false);
     return $result;
 }
 public function actionIndex()
 {
     $mail = new Zend_Mail('utf-8');
     $mail->setHeaderEncoding(Zend_Mime::ENCODING_QUOTEDPRINTABLE);
     $mail->addTo("*****@*****.**", "Alexander Makarov");
     $mail->setFrom("*****@*****.**", "Robot");
     $mail->setSubject("Test email");
     $mail->setBodyText("Hello, world!");
     $mail->setBodyHtml("Hello, <strong>world</strong>!");
     $mail->send();
     echo "OK";
 }
Exemple #3
0
 public static function sendMail($to, $subject, $message)
 {
     $transport = new Zend_Mail_Transport_Smtp('smtp.yuekegu.com', self::$_config);
     $mail = new Zend_Mail('UTF-8');
     $mail->setHeaderEncoding(Zend_Mime::ENCODING_BASE64);
     $mail->setBodyHtml($message);
     $mail->setFrom('*****@*****.**', 'Administrator');
     //		$mail->addTo(Yii::app()->params['mail'], Yii::app()->params['author']);
     $mail->addTo($to, 'Receiver');
     $mail->setSubject($subject);
     $mail->send($transport);
     UtilHelper::writeToFile($mail, 'a+');
 }
 public function actionIndex()
 {
     Yii::import('application.vendors.*');
     require "Zend/Mail.php";
     $mail = new Zend_Mail('utf-8');
     $mail->setHeaderEncoding(Zend_Mime::ENCODING_QUOTEDPRINTABLE);
     // change to your email
     $mail->addTo("*****@*****.**", "Alexander Makarov");
     $mail->setFrom("*****@*****.**", "Robot");
     $mail->setSubject("Test email");
     $mail->setBodyText("Hello, world!");
     $mail->setBodyHtml("Hello, <strong>world</strong>!");
     $mail->send();
     echo "OK";
 }
 private function sendEmail($emailMessage, $recipients)
 {
     $mailerConfig = Zend_Registry::get("config")->mail;
     $transport = new Zend_Mail_Transport_Smtp($mailerConfig->host, $mailerConfig->smtpconfig->toArray());
     Zend_Mail::setDefaultTransport($transport);
     $email = new Zend_Mail('UTF-8');
     $email->setHeaderEncoding(Zend_Mime::ENCODING_BASE64);
     $email->addHeader('Content-type', 'text/html');
     $email->setFrom($emailMessage->getSenderAddress(), $emailMessage->getSenderName());
     $email->setSubject($emailMessage->getSubject());
     $email->setBodyHtml($emailMessage->getBody(), 'UTF-8');
     foreach ($recipients as $recipient) {
         $email->addBcc($recipient->getAddress(), $recipient->getName());
     }
     $email->send();
 }
 public function sendExternalMailToStudent($studentId, $subj, $text)
 {
     $db = Zend_Db_Table_Abstract::getDefaultAdapter();
     $select = $db->select()->from('users')->where("u_id={$studentId}");
     $stmp = $select->query();
     $res = $stmp->fetchAll();
     $external = $res[0]['u_external_emails'];
     if (!$external) {
         return;
     }
     $username = $res[0]['u_name'];
     $userfamilyname = $res[0]['u_family_name'];
     $email = $res[0]['u_email'];
     $mail = new Zend_Mail('UTF-8');
     $mail->setHeaderEncoding(Zend_Mime::ENCODING_BASE64);
     $mail->setBodyHtml($text)->setFrom("*****@*****.**", "Admin")->addTo($email)->setSubject($subj);
     // $mail->send();
 }
Exemple #7
0
 public function newUserCeated($data)
 {
     $config = array('auth' => 'login', 'username' => 'USERNAME', 'password' => 'SENHAGMAIL', 'ssl' => 'ssl', 'port' => 465);
     // Optional port number supplied
     $transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);
     $html = new Zend_View();
     $html->setScriptPath(APPLICATION_PATH . '/modules/home/views/helpers/emails');
     $html->assign('name', $data['name']);
     $html->assign('login', $data['login']);
     $html->assign('date', date('d/m/Y H:i:s', $data['timestamp']));
     $mail = new Zend_Mail("UTF-8");
     $bodyText = $html->render('newUser.phtml');
     $mail->setFrom(self::$fromEmail, self::$fromName);
     $mail->addTo('*****@*****.**');
     $mail->setHeaderEncoding(Zend_Mime::ENCODING_BASE64);
     $mail->setSubject('Novo usuário cadastrado!');
     $mail->setBodyHtml($bodyText);
     $mail->send($transport);
 }
Exemple #8
0
 function mail($data)
 {
     $mail = new Zend_Mail('utf-8');
     $mail->setType(Zend_Mime::MULTIPART_ALTERNATIVE);
     $mail->setHeaderEncoding(Zend_Mime::ENCODING_BASE64);
     $body = $this->view->partial('mail/frame.phtml', array('message' => @$data['body'] ? $data['body'] : $this->view->partial('mail/' . $data['view'] . '.phtml', $data)));
     preg_match_all('/src\\=\\"\\/(img|upload\\/mce\\/image)\\/([^\\"]+)\\"/si', $body, $res);
     if (@$res[1]) {
         $r = array();
         foreach ($res[1] as $k => $v) {
             $fn = PUBLIC_PATH . '/' . $res[1][$k] . '/' . $res[2][$k];
             $s = getimagesize($fn);
             if ($s) {
                 $cid = md5($res[1][$k] . '/' . $res[2][$k]);
                 $at = $mail->createAttachment(file_get_contents($fn), $s['mime'], Zend_Mime::DISPOSITION_INLINE, Zend_Mime::ENCODING_BASE64);
                 $at->id = $cid;
                 $r[] = 'src="cid:' . $cid . '"';
             } else {
                 $r[] = $res[0][$k];
             }
         }
         $body = str_ireplace($res[0], $r, $body);
     }
     preg_match_all('/href\\=\\"\\/upload\\/mce\\/file\\/([^\\"]+)\\"/si', $body, $res);
     if (@$res[1]) {
         $r = array();
         foreach ($res[1] as $k => $v) {
             $fn = PUBLIC_PATH . '/upload/mce/file/' . $res[1][$k];
             $s = file_exists($fn);
             if ($s) {
                 $cid = md5('upload/mce/file/' . $res[1][$k]);
                 $at = $mail->createAttachment(file_get_contents($fn), Zend_Mime::TYPE_OCTETSTREAM, Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, basename($fn));
                 $at->id = $cid;
                 $r[] = 'href="cid:' . $cid . '"';
             } else {
                 $r[] = $res[0][$k];
             }
         }
         $body = str_ireplace($res[0], $r, $body);
     }
     $mail->setBodyHtml($body);
     $fm = $this->view->txt('site_mail');
     $from = @$data['from'] ? $data['from'] : $this->view->txt('site_mail');
     $to = @$data['to'] ? $data['to'] : $this->view->txt('site_mail');
     $to = preg_split('/(\\;|\\,)/i', $to);
     $reply_to = @$data['reply_to'];
     $from_name = @$data['from_name'] ? $data['from_name'] : ($from == $fm ? $this->view->txt('site_title') : $from);
     if ($reply_to) {
         $mail->setReplyTo($reply_to, $from_name);
     }
     $mail->setFrom($from, $from_name);
     $tn = @$data['to_name'] ? $data['to_name'] : $to;
     foreach ($to as $n => $el) {
         $el = trim($el);
         if (!$el) {
             continue;
         }
         $tn_el = is_array($tn) ? isset($tn[$n]) ? $tn[$n] : @$tn[0] : $tn;
         $mail->addTo($el, $tn_el);
     }
     if (@$data['subject_full']) {
         $mail->setSubject($data['subject_full']);
     } else {
         $mail->setSubject($this->view->txt('site_title') . ($data['subject'] ? ' — ' . $data['subject'] : ''));
     }
     $ok = false;
     try {
         $tr = null;
         $bt = Zend_Controller_Front::getInstance()->getParam('bootstrap');
         if ($bt) {
             $config = $bt->getOptions();
             if (@$config['mail']) {
                 if (@$config['mail']['transports'] && @$config['mail']['transports']['transport']) {
                     foreach ($config['mail']['transports']['transport'] as $k => $v) {
                         $class = 'Zend_Mail_Transport_' . ucfirst($v);
                         $tr = new $class($config['mail']['transports'][$v]['host'][$k], array('host' => $config['mail']['transports'][$v]['host'][$k], 'port' => $config['mail']['transports'][$v]['port'][$k], 'auth' => $config['mail']['transports'][$v]['auth'][$k], 'username' => $config['mail']['transports'][$v]['username'][$k], 'password' => $config['mail']['transports'][$v]['password'][$k], 'ssl' => $config['mail']['transports'][$v]['ssl'][$k]));
                         try {
                             $mail->send($tr);
                             $ok = true;
                             break;
                         } catch (Exception $e) {
                             //$ok = false;
                             //@file_put_contents(DATA_PATH.'/mail-'.time().microtime(true).'.txt', var_export($e, 1));
                         }
                     }
                     $tr = null;
                 } else {
                     if (@$config['mail']['transport']) {
                         $k = $config['mail']['transport'];
                         if (@$config['mail'][$k] && @$config['mail'][$k]['host']) {
                             try {
                                 $class = 'Zend_Mail_Transport_' . ucfirst($k);
                                 $tr = new $class($config['mail']['smtp']['host'], $config['mail'][$k]);
                             } catch (Exception $e) {
                                 $tr = null;
                                 //$ok = false;
                             }
                         }
                     }
                 }
             }
         }
         if (!$ok) {
             $ok = $mail->send($tr);
         }
     } catch (Zend_Mail_Transport_Exception $e) {
         $ok = false;
     }
     return $ok;
 }
Exemple #9
0
 /**
  * 
  * @return Zend_Mail
  */
 public function getMailer()
 {
     $mail = new Zend_Mail('utf-8');
     $mail->setHeaderEncoding(Zend_Mime::ENCODING_BASE64);
     return $mail;
 }
Exemple #10
0
 /**
  * SendEmail
  * Smtp Configuration.
  * If you would like to use the smtp authentication, you have to add 
  * the parameters in the Setting Module of the Control Panel
  * 
  * @param string $from
  * @param string or array $to
  * @param string $bcc
  * @param string $subject
  * @param string $body
  * @param string $html
  * @param string $inreplyto
  * @param string/array $attachments
  * @return boolean|multitype:unknown NULL
  */
 public static function SendEmail($from, $to, $bcc = NULL, $subject, $body, $html = false, $inreplyto = NULL, $attachments = NULL, $replyto = NULL, $cc = null)
 {
     $transport = null;
     $config = array();
     $host = Settings::findbyParam('smtp_host');
     if (!empty($host)) {
         $username = Settings::findbyParam('smtp_user');
         $password = Settings::findbyParam('smtp_password');
         $port = Settings::findbyParam('smtp_port');
         $port = !empty($port) ? $port : 25;
         if (!empty($username) && !empty($password)) {
             $config = array('auth' => 'login', 'username' => $username, 'password' => $password, 'port' => $port);
         }
         $transport = new Zend_Mail_Transport_Smtp($host, $config);
     }
     $mail = new Zend_Mail('UTF-8');
     $mail->setHeaderEncoding(Zend_Mime::ENCODING_BASE64);
     if (!empty($attachments)) {
         if (is_array($attachments)) {
             foreach ($attachments as $attachment) {
                 if (file_exists($attachment)) {
                     $filename = basename($attachment);
                     // Get the content of the file
                     $content = file_get_contents($attachment);
                     // Create the attachment
                     $zend_attachment = new Zend_Mime_Part($content);
                     $zend_attachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
                     $zend_attachment->encoding = Zend_Mime::ENCODING_BASE64;
                     $zend_attachment->filename = $filename;
                     $mail->addAttachment($zend_attachment);
                 }
             }
         } else {
             if (file_exists($attachments)) {
                 $filename = basename($attachments);
                 // Get the content of the file
                 $content = file_get_contents($attachments);
                 // Create the attachment
                 $zend_attachment = new Zend_Mime_Part($content);
                 $zend_attachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
                 $zend_attachment->encoding = Zend_Mime::ENCODING_BASE64;
                 $zend_attachment->filename = $filename;
                 $mail->addAttachment($zend_attachment);
             }
         }
     }
     if (!empty($inreplyto)) {
         $mail->addHeader("In-Reply-To", $inreplyto);
     }
     if (!empty($replyto)) {
         $mail->setReplyTo($replyto);
     }
     // If the body of the message contains the HTML tags
     // we have to override the $html variable in order to send the html message by email
     if (self::isHtml($body)) {
         $html = true;
     }
     if ($html) {
         $mail->setBodyHtml($body, null, Zend_Mime::ENCODING_8BIT);
     } else {
         $mail->setBodyText($body);
     }
     if (is_array($from)) {
         $mail->setFrom($from['email'], $from['name']);
     } else {
         $mail->setFrom($from);
     }
     // If the $to is a group of emails addresses
     if (is_array($to)) {
         foreach ($to as $recipient) {
             $mail->addTo($recipient);
         }
     } else {
         $mail->addTo($to);
     }
     if (!empty($bcc)) {
         if (is_array($bcc) && count($bcc) > 0) {
             foreach ($bcc as $b) {
                 $mail->addBcc($b);
             }
         } else {
             $mail->addBcc($bcc);
         }
     }
     if (!empty($cc)) {
         if (is_array($cc) && count($cc) > 0) {
             foreach ($cc as $c) {
                 $mail->addCc($c);
             }
         } else {
             $mail->addCc($cc);
         }
     }
     $mail->setSubject($subject);
     try {
         $mail->send($transport);
         // All good, log to DB
         if (is_array($to)) {
             foreach ($to as $recipient) {
                 // get customer_id
                 $Customers = Customers::findbyemail($recipient);
                 if (is_object($Customers) && is_object($Customers->{0}) && isset($Customers->{0}->customer_id)) {
                     $customerId = $Customers->{0}->customer_id;
                 }
                 if (EmailsTemplatesSends::saveIt($customerId, $from, $recipient, $subject, $cc, $bcc, $html, $body)) {
                     Shineisp_Commons_Utilities::log("An email has been sent to {$recipient}", 'notice.log');
                     // log the data
                 }
             }
         } else {
             // get customer_id
             $Customers = Customers::findbyemail($to);
             if (is_object($Customers) && is_object($Customers->{0}) && isset($Customers->{0}->customer_id)) {
                 $customerId = $Customers->{0}->customer_id;
             }
             if (EmailsTemplatesSends::saveIt($customerId, $from, $to, $subject, $cc, $bcc, $html, $body)) {
                 Shineisp_Commons_Utilities::log("An email has been sent to {$to}", 'notice.log');
                 // log the data
             }
         }
         return true;
     } catch (Exception $e) {
         // log the data
         Shineisp_Commons_Utilities::log($e->getMessage());
         return array('email' => $to, 'message' => $e->getMessage());
     }
     return false;
 }
 public static function execute($subject, $to, $from, $body)
 {
     if (!$to) {
         return false;
     }
     self::initialize();
     opApplicationConfiguration::registerZend();
     $subject = mb_convert_kana($subject, 'KV');
     $mailer = new Zend_Mail('iso-2022-jp');
     $mailer->setHeaderEncoding(Zend_Mime::ENCODING_BASE64)->setFrom($from)->addTo($to)->setSubject(mb_encode_mimeheader($subject, 'iso-2022-jp'))->setBodyText(mb_convert_encoding($body, 'JIS', 'UTF-8'), 'iso-2022-jp', Zend_Mime::ENCODING_7BIT);
     if ($envelopeFrom = sfConfig::get('op_mail_envelope_from')) {
         $mailer->setReturnPath($envelopeFrom);
     }
     $result = $mailer->send();
     Zend_Loader::registerAutoLoad('Zend_Loader', false);
     return $result;
 }
 /**
  *
  * @param mixed $config
  * @param array $replacement
  * @param array $attachment
  * @param bool $log
  * @param integer $vsprintfTimes
  * @param callback $filter
  * @return bool
  */
 public function send($config = null, $replacement = array(), $attachment = array(), $log = false, $vsprintfTimes = 1, $filter = null)
 {
     if (is_scalar($config)) {
         $config = $this->getConfig($config);
     }
     if (isset($config['mail'])) {
         $config = $config['mail'];
     }
     //TODO
     if (count($config) > 0 && count($attachment) > 0) {
         foreach ($attachment as $att) {
             if ($att->filename) {
                 $extension = strtolower(pathinfo(strval($att->filename), PATHINFO_EXTENSION));
                 if (isset(EhrlichAndreas_Util_Mime::$MIME_TYPE[$extension])) {
                     $att->type = EhrlichAndreas_Util_Mime::$MIME_TYPE[$extension];
                 }
             }
         }
     }
     if (!is_null($filter)) {
         if ($config[0]['zfversion'] == 1) {
             $tmp = Zend_Json::encode($replacement);
         } elseif ($config[0]['zfversion'] == 2) {
             $callback = array('Zend\\Json\\Json', 'encode');
             $param_arr = array($tmp);
             $tmp = call_user_func_array($callback, $param_arr);
         }
         $tmp = base64_encode($tmp);
         $tmp = ' replacement=\'' . $tmp . '\'';
     }
     $send = true;
     foreach ($config as $conf) {
         $fromEmail = EhrlichAndreas_Util_Vsprintf::vsprintf($conf['from']['email'], $replacement, $vsprintfTimes);
         $fromName = null;
         $replytoEmail = null;
         $replytoName = null;
         $toEmail = array();
         $toName = array();
         $ccEmail = array();
         $ccName = array();
         $bccEmail = array();
         $bccName = array();
         $header = array();
         $subject = null;
         $bodyHtml = null;
         $bodyText = null;
         if (isset($conf['from']['name'])) {
             $fromName = EhrlichAndreas_Util_Vsprintf::vsprintf($conf['from']['name'], $replacement, $vsprintfTimes);
         }
         if (isset($conf['replyto']['email'])) {
             $replytoEmail = EhrlichAndreas_Util_Vsprintf::vsprintf($conf['replyto']['email'], $replacement, $vsprintfTimes);
         }
         if (isset($conf['replyto']['name'])) {
             $replytoName = EhrlichAndreas_Util_Vsprintf::vsprintf($conf['replyto']['name'], $replacement, $vsprintfTimes);
         }
         if (count($conf['to']) > 0) {
             foreach ($conf['to'] as $key => $value) {
                 $email = EhrlichAndreas_Util_Vsprintf::vsprintf($value['email'], $replacement, $vsprintfTimes);
                 $name = '';
                 if (isset($value['name'])) {
                     $name = EhrlichAndreas_Util_Vsprintf::vsprintf($value['name'], $replacement, $vsprintfTimes);
                 }
                 //TODO
                 /*
                 					if (isset($value['name']) && $value['name'] === $name)
                 					{
                 						$name = null;
                 					}
                 */
                 $toEmail[$key] = $email;
                 $toName[$key] = $name;
             }
         }
         if (count($conf['cc']) > 0) {
             foreach ($conf['cc'] as $key => $value) {
                 $email = EhrlichAndreas_Util_Vsprintf::vsprintf($value['email'], $replacement, $vsprintfTimes);
                 $name = '';
                 if (isset($value['name'])) {
                     $name = EhrlichAndreas_Util_Vsprintf::vsprintf($value['name'], $replacement, $vsprintfTimes);
                 }
                 $ccEmail[$key] = $email;
                 $ccName[$key] = $name;
             }
         }
         if (count($conf['bcc']) > 0) {
             foreach ($conf['bcc'] as $key => $value) {
                 $email = EhrlichAndreas_Util_Vsprintf::vsprintf($value['email'], $replacement, $vsprintfTimes);
                 $name = '';
                 if (isset($value['name'])) {
                     $name = EhrlichAndreas_Util_Vsprintf::vsprintf($value['name'], $replacement, $vsprintfTimes);
                 }
                 $bccEmail[$key] = $email;
                 $bccName[$key] = $name;
             }
         }
         if (count($conf['header']) > 0) {
             foreach ($conf['header'] as $key => $value) {
                 if (!isset($value['append'])) {
                     $value['append'] = false;
                 }
                 $header[] = $value;
             }
         }
         /*
         			if (isset($conf['subject']) && strlen($conf['subject']) > 0)
         			{
            $subject = $conf['subject'];
            
            if (!is_null($filter))
            {
                $subject = str_replace(' replacement=\'%replacement%\'', $tmp, $subject);
            }
            else
            {
                $subject = preg_replace('#\\[base64.*\\[\\/base64\\]#ui', '', $subject);
            }
            
            if (!is_null($filter))
            {
                $subject = str_replace(' replacement=\'%replacement%\'', $tmp, $subject);
                
                $subject = EhrlichAndreas_Util_Vsprintf::vsprintf($subject, $replacement, $vsprintfTimes);
            }
            else
            {
                $subject = EhrlichAndreas_Util_Vsprintf::vsprintf($subject, $replacement, 1);
                
                $subject = preg_replace('#\\[base64.*\\[\\/base64\\]#ui', '', $subject);
                
                $subject = EhrlichAndreas_Util_Vsprintf::vsprintf($subject, $replacement, $vsprintfTimes - 1);
            }
         			}
         * 
         */
         if (isset($conf['subject']) && strlen($conf['subject']) > 0) {
             $subject = $conf['subject'];
             if (!is_null($filter)) {
                 $subject = str_replace(' replacement=\'%replacement%\'', $tmp, $subject);
                 $subject = EhrlichAndreas_Util_Vsprintf::vsprintf($subject, $replacement, $vsprintfTimes);
             } else {
                 for ($vsprintfTime = 0; $vsprintfTime < $vsprintfTimes; $vsprintfTime++) {
                     $subject = preg_replace('#\\[base64.*\\[\\/base64\\]#si', '', $subject);
                     $subject = str_replace(' replacement=\'%replacement%\'', '', $subject);
                     $subject = str_replace(' replacement=\'\'', '', $subject);
                     $subject = EhrlichAndreas_Util_Vsprintf::vsprintf($subject, $replacement);
                 }
             }
         }
         if (!is_null($subject) && !is_null($filter)) {
             $subject = call_user_func_array($filter, array($subject));
         }
         /*
         			if (isset($conf['body']['html']) && strlen($conf['body']['html']) > 0)
         			{
            $bodyHtml = $conf['body']['html'];
            
            if (!is_null($filter))
            {
                $bodyHtml = str_replace(' replacement=\'%replacement%\'', $tmp, $bodyHtml);
                
                $bodyHtml = EhrlichAndreas_Util_Vsprintf::vsprintf($bodyHtml, $replacement, $vsprintfTimes);
            }
            else
            {
                $bodyHtml = EhrlichAndreas_Util_Vsprintf::vsprintf($bodyHtml, $replacement, 1);
                
                $bodyHtml = preg_replace('#\\[base64.*\\[\\/base64\\]#ui', '', $bodyHtml);
                
                $bodyHtml = EhrlichAndreas_Util_Vsprintf::vsprintf($bodyHtml, $replacement, $vsprintfTimes - 1);
            }
         			}
         * 
         */
         if (isset($conf['body']['html']) && strlen($conf['body']['html']) > 0) {
             $bodyHtml = $conf['body']['html'];
             if (!is_null($filter)) {
                 $bodyHtml = str_replace(' replacement=\'%replacement%\'', $tmp, $bodyHtml);
                 $bodyHtml = EhrlichAndreas_Util_Vsprintf::vsprintf($bodyHtml, $replacement, $vsprintfTimes);
             } else {
                 for ($vsprintfTime = 0; $vsprintfTime < $vsprintfTimes; $vsprintfTime++) {
                     $bodyHtml = preg_replace('#\\[base64.*\\[\\/base64\\]#si', '', $bodyHtml);
                     $bodyHtml = str_replace(' replacement=\'%replacement%\'', '', $bodyHtml);
                     $bodyHtml = str_replace(' replacement=\'\'', '', $bodyHtml);
                     $bodyHtml = EhrlichAndreas_Util_Vsprintf::vsprintf($bodyHtml, $replacement);
                 }
             }
         }
         if (!is_null($bodyHtml) && !is_null($filter)) {
             $bodyHtml = call_user_func_array($filter, array($bodyHtml));
         }
         if (!is_null($bodyHtml)) {
             $bodyHtml = preg_replace('#\\r?\\n|\\r\\n?#', $conf['eol'], $bodyHtml);
         }
         /*
         			if (isset($conf['body']['text']) && strlen($conf['body']['text']) > 0)
         			{
            $bodyText = $conf['body']['text'];
            
            if (!is_null($filter))
            {
                $bodyText = str_replace(' replacement=\'%replacement%\'', $tmp, $bodyText);
                
                $bodyText = EhrlichAndreas_Util_Vsprintf::vsprintf($bodyText, $replacement, $vsprintfTimes);
            }
            else
            {
                $bodyText = EhrlichAndreas_Util_Vsprintf::vsprintf($bodyText, $replacement, 1);
                
                $bodyText = preg_replace('#\\[base64.*\\[\\/base64\\]#ui', '', $bodyText);
                
                $bodyText = EhrlichAndreas_Util_Vsprintf::vsprintf($bodyText, $replacement, $vsprintfTimes - 1);
            }
            
         				$bodyText = EhrlichAndreas_Util_Vsprintf::vsprintf($bodyText, $replacement, $vsprintfTimes);
         			}
         * 
         */
         if (isset($conf['body']['text']) && strlen($conf['body']['text']) > 0) {
             $bodyText = $conf['body']['text'];
             if (!is_null($filter)) {
                 $bodyText = str_replace(' replacement=\'%replacement%\'', $tmp, $bodyText);
                 $bodyText = EhrlichAndreas_Util_Vsprintf::vsprintf($bodyText, $replacement, $vsprintfTimes);
             } else {
                 for ($vsprintfTime = 0; $vsprintfTime < $vsprintfTimes; $vsprintfTime++) {
                     $bodyText = preg_replace('#\\[base64.*\\[/base64\\]#si', '', $bodyText);
                     $bodyText = str_replace(' replacement=\'%replacement%\'', '', $bodyText);
                     $bodyText = str_replace(' replacement=\'\'', '', $bodyText);
                     $bodyText = EhrlichAndreas_Util_Vsprintf::vsprintf($bodyText, $replacement);
                 }
             }
         }
         if (!is_null($bodyText) && !is_null($filter)) {
             $bodyText = call_user_func_array($filter, array($bodyText));
         }
         if (!is_null($bodyText)) {
             $bodyText = preg_replace('#\\r?\\n|\\r\\n?#', $conf['eol'], $bodyText);
         }
         if ($conf['zfversion'] == 1) {
             //require_once 'Zend/Mail.php';
             $message = new Zend_Mail($conf['charset']);
             $message->setHeaderEncoding($conf['encoding']);
         } elseif ($conf['zfversion'] == 2) {
             $classMailMessage = 'Zend\\Mail\\Message';
             $message = new $classMailMessage();
             $message->setEncoding($conf['charset']);
             $classMimeMessage = 'Zend\\Mime\\Message';
             $mimeBody = new $classMimeMessage();
             $message->setBody($mimeBody);
             $headers = $message->getHeaders();
             $headers->setEncoding('ASCII');
         }
         $message->setFrom($fromEmail, $fromName);
         if (!is_null($replytoEmail)) {
             $message->setReplyTo($replytoEmail, $replytoName);
         }
         foreach ($toEmail as $key => $email) {
             $name = $toName[$key];
             $message->addTo($email, $name);
         }
         foreach ($ccEmail as $key => $email) {
             $name = $ccName[$key];
             $message->addCc($email, $name);
         }
         foreach ($bccEmail as $key => $email) {
             $name = $bccName[$key];
             $message->addBcc($email, $name);
         }
         if ($conf['zfversion'] == 1) {
             foreach ($header as $key => $value) {
                 $message->addHeader($value['name'], $value['value'], $value['append']);
             }
         } elseif ($conf['zfversion'] == 2) {
             $headers = $message->getHeaders();
             //$headers->setEncoding($conf['charset']);
             foreach ($header as $key => $value) {
                 $classGenericMultiHeader = 'Zend\\Mail\\Header\\GenericMultiHeader';
                 $headerTmp = new $classGenericMultiHeader($value['name'], $value['value']);
                 $headerTmp->setEncoding($conf['charset']);
                 $headers->addHeader($headerTmp);
             }
         }
         if (!is_null($subject)) {
             $message->setSubject($subject);
         }
         if ($conf['zfversion'] == 1) {
             if (!is_null($bodyHtml)) {
                 $message->setBodyHtml($bodyHtml, $conf['charset'], $conf['encoding']);
             }
             if (!is_null($bodyText)) {
                 $message->setBodyText($bodyText, $conf['charset'], $conf['encoding']);
             }
         } elseif ($conf['zfversion'] == 2) {
             $htmlPart = null;
             $textPart = null;
             //$mimeMessage = null;
             if (!is_null($bodyText)) {
                 $classMimePart = 'Zend\\Mime\\Part';
                 $textPart = new $classMimePart($bodyText);
                 $textPart->type = 'text/plain';
                 $textPart->charset = $conf['charset'];
                 $textPart->encoding = $conf['encoding'];
                 $message->getBody()->addPart($textPart);
                 $classGenericMultiHeader = 'Zend\\Mail\\Header\\GenericMultiHeader';
                 $headerTmp = new $classGenericMultiHeader('content-type', 'text/plain; charset=' . $conf['charset']);
                 $headerTmp->setEncoding('ASCII');
                 $headers->removeHeader('content-type');
                 $headers->addHeader($headerTmp);
             }
             if (!is_null($bodyHtml)) {
                 $classMimePart = 'Zend\\Mime\\Part';
                 $htmlPart = new $classMimePart($bodyHtml);
                 $htmlPart->type = 'text/html';
                 $htmlPart->charset = $conf['charset'];
                 $htmlPart->encoding = $conf['encoding'];
                 $message->getBody()->addPart($htmlPart);
                 $classGenericMultiHeader = 'Zend\\Mail\\Header\\GenericMultiHeader';
                 $headerTmp = new $classGenericMultiHeader('content-type', 'text/html; charset=' . $conf['charset']);
                 $headerTmp->setEncoding('ASCII');
                 $headers->removeHeader('content-type');
                 $headers->addHeader($headerTmp);
             }
             /*
             				if (!is_null($htmlPart) || !is_null($textPart))
             				{
             					$mimeMessage = new Zend\Mime\Message();
             				}
             				
             				if (!is_null($htmlPart))
             				{
             					$mimeMessage->addPart($htmlPart);
             				}
             				
             				if (!is_null($textPart))
             				{
             					$mimeMessage->addPart($textPart);
             				}
             				
             				if (!is_null($mimeMessage))
             				{
             					$alternativePart = new Zend\Mime\Part($mimeMessage->generateMessage());
             					
             					$alternativePart->type = 'multipart/alternative';
             					
             					$alternativePart->boundary = $mimeMessage->getMime()->boundary();
             					
             					$alternativePart->charset = $conf['charset'];
             					
             					//$alternativePart->encoding = $conf['encoding'];
             					
             					
             					$message->getBody()->addPart($alternativePart);
             				}
             * 
             */
         }
         if ($conf['zfversion'] == 1) {
             if (isset($conf['attachment']) && strlen($conf['attachment']) > 0 && $conf['attachment']) {
                 foreach ($attachment as $att) {
                     $message->addAttachment($att);
                 }
             }
         } elseif ($conf['zfversion'] == 2) {
             //TODO add attachements
         }
         /*
         * 
         * TODO add attachements
         * 
         			if (count($config)>0&&count($attachment)>0) {
         				foreach ($attachment as $att) {
         					if ($att->filename) {
         						$extension = strtolower(pathinfo(strval($att->filename),PATHINFO_EXTENSION));
         						if (isset(EhrlichAndreas_Util_Mime::$MIME_TYPE[$extension])) {
         							$att->type = EhrlichAndreas_Util_Mime::$MIME_TYPE[$extension];
         						}
         					}
         				}
         			}
         			
         			if (isset($conf['attachment'])&&strlen($conf['attachment'])>0&&$conf['attachment']) {
         				foreach ($attachment as $att) {
         					$mail->addAttachment($att);
         				}
         			}
         * 
         */
         if ($conf['zfversion'] == 1) {
         } elseif ($conf['zfversion'] == 2) {
             $headers = $message->getHeaders();
             //$headers->setEncoding('ASCII');
             $classGenericMultiHeader = 'Zend\\Mail\\Header\\GenericMultiHeader';
             $headerTmp = new $classGenericMultiHeader('Content-Transfer-Encoding', $conf['encoding']);
             $headerTmp->setEncoding('ASCII');
             $headers->addHeader($headerTmp);
             if (!is_null($bodyText) && !is_null($bodyHtml)) {
                 $headers->removeHeader('Content-Transfer-Encoding');
                 $headers->removeHeader('content-type');
                 $boundary = $message->getBody()->getMime()->boundary();
                 $classGenericMultiHeader = 'Zend\\Mail\\Header\\GenericMultiHeader';
                 $headerTmp = new $classGenericMultiHeader('content-type', 'multipart/alternative; boundary="' . $boundary . '"');
                 $headerTmp->setEncoding('ASCII');
                 $headers->addHeader($headerTmp);
             }
             if (false && $message->getBody()->isMultiPart()) {
                 $classGenericMultiHeader = 'Zend\\Mail\\Header\\GenericMultiHeader';
                 $headerTmp = new $classGenericMultiHeader('content-type', 'multipart/alternative; charset=' . $conf['charset']);
                 $headerTmp->setEncoding('ASCII');
                 $headers->addHeader($headerTmp);
             }
         }
         /* *
            echo '<pre>';
            var_dump
            (
                $fromEmail,
                $fromName,
                $replytoEmail,
                $replytoName,
                $toEmail,
                $toName,
                $ccEmail,
                $ccName,
                $bccEmail,
                $bccName,
                $header,
                $subject,
                $bodyHtml,
                $bodyText
            );
            //print_r($replacement);
            //die();
            /* */
         if ($conf['zfversion'] == 1) {
             $defaultTranslator = Zend_Validate_Abstract::getDefaultTranslator();
             if (is_object($defaultTranslator)) {
                 Zend_Validate_Abstract::setDefaultTranslator(null);
                 $defaultTranslatorOptions = $defaultTranslator->getOptions();
                 $defaultTranslator->setOptions(array('logUntranslated' => false));
             }
         } else {
         }
         $messageTransport = $conf['transport'];
         try {
             $messageTransport->send($message);
             $sendTmp = true;
         } catch (Exception $e) {
             $sendTmp = false;
         }
         $send = $send && $sendTmp;
         if ($conf['zfversion'] == 1) {
             if (is_object($defaultTranslator)) {
                 $defaultTranslator->setOptions($defaultTranslatorOptions);
                 Zend_Validate_Abstract::setDefaultTranslator($defaultTranslator);
             }
         } else {
         }
     }
     return $send;
 }
 public function sendWelcomeMail($email, $username, $userId)
 {
     $body = $body . "<p align='right' dir='RTL'>";
     $body .= " {$username} ";
     $body .= "שלום";
     $body .= "<br/>";
     $body .= "ברוכים הבאים לטיפולית אונליין. מייל זה נשלח באופן אוטומטי לאחר מילוי פרטים אישיים באתר ";
     $body .= "<br/>";
     $body .= "עימך קשר בזמן הקרוב בכדי להתאים לך תרגול יוגה אישי.";
     $body .= "<br/><br/>";
     $body .= "מרכז הלמידה שנפתח בעבורך הוא חלון לעולם של ידע אודות היוגה. מטרתו של מרכז ";
     $body .= "<br/>";
     $body .= "הלמידה הוא לעודד וללמד יוגה בבית וליישם את עקרונותיה בחיי היום יום. באמצעות מרכז ";
     $body .= "<br/>";
     $body .= "הלמידה אפשר להיות בקשר עם מדריכנו ולספק משוב על איכות התרגול, העדפות ובקשות ";
     $body .= "<br/>";
     $body .= "מיוחדות.";
     $body .= "<br/><br/>";
     $body .= "במרכז הלמידה מחכה לך עתה סרטון הסבר ראשון. את/ה מוזמנ/ת לצפות בסרטון וליישם  ";
     $body .= "<br/>";
     $body .= "את עקרונות היוגה כבר בתרגול הראשון.";
     $body .= "<br/><br/>";
     $body .= "חשוב: עליך להודיע לנו על כל שינוי במצבך הבריאותי או על כל עניין גופני אחר הקשור ";
     $body .= "<br/>";
     $body .= "לתרגול כמו קושי מיוחד בביצוע התרגילים, כאב או מגבלה אחרת. נבקש ממך לדווח על כל ";
     $body .= "<br/>";
     $body .= "שיפור שחל בעקבות התרגול. היוגה שאנו מלמדים מעוררת כוחות ריפוי פנימיים. את/ה  ";
     $body .= "<br/>";
     $body .= "מוזמנים לתרגל בקביעות ולהיעזר במרכז הלמידה.";
     $body .= "<br/><br/>";
     $body .= "צוות טיפולית אונליין עומד לרשותך במייל: ";
     $body .= "<a href='*****@*****.**'>info@tipulitonline.co.il</a>";
     $body .= "<br/>";
     $body .= "כתובת האינטרנט שלנו היא: ";
     $body .= "<a href='http://www.tipulitonline.co.il'>tipulitonline.co.il</a>'";
     $body .= "<br/><br/>";
     $body .= "בברכה,";
     $body .= "<br/><br/>";
     $body .= "צוות טיפולית אונליין";
     $body = $body . "</p>";
     $mailExchange = new Student_Model_MailExchange();
     $mailExchange->sendMessageFromTeacherToStudent($userId, 1, 'ברוכים הבאים לטיפולית אונליין', $body);
     $mail = new Zend_Mail('UTF-8');
     $mail->setHeaderEncoding(Zend_Mime::ENCODING_BASE64);
     $mail->setBodyHtml($body)->setFrom("*****@*****.**", "טיפולית אונליין")->addTo($email)->setSubject("ברוכים הבאים לטיפולית אונליין");
     $mail->send();
 }
Exemple #14
0
 $opts->setOption('ignoreCase', true);
 $options = $opts->parse();
 $new = argsToArray($options);
 print_r($new);
 if (isset($opts->e)) {
     echo "I got the a option " . $new["e"] . " \n";
     $subject = "Teste zend " . Zend_Date::now();
     $message = "<h2>Uma menssagem de teste em " . Zend_Date::now() . "</h2>";
     //$tr = new Zend_Mail_Transport_Sendmail('*****@*****.**');
     //Zend_Mail::setDefaultTransport($tr);
     $mail = new Zend_Mail('utf-8');
     $mail->addTo($new["e"]);
     $mail->setSubject($subject);
     $mail->setBodyHtml($message);
     $mail->setFrom('*****@*****.**', 'Voluntário');
     $mail->setHeaderEncoding(Zend_Mime::ENCODING_BASE64);
     //print_r($mail);exit;
     //Send it!
     $sent = true;
     try {
         $mail->send();
         echo "send teste \n";
     } catch (Exception $e) {
         print_r($e);
         $sent = false;
     }
     //Do stuff (display error message, log it, redirect user, etc)
     if ($sent) {
         echo "Mail was sent successfully. \n";
     } else {
         echo "Mail failed to send. \n";
 protected function sendMail($subject, $address, $from, $body)
 {
     if (null === $this->transport) {
         $this->transport = $this->getTransport();
     }
     // This code prevents memory leak.
     $this->sendCount++;
     if ($this->sendCount > 100) {
         unset($this->transport);
         $this->sendCount = 0;
         $this->transport = $this->getTransport();
     }
     $subject = mb_convert_kana($subject, 'KV');
     $mailer = new Zend_Mail('iso-2022-jp');
     $mailer->setHeaderEncoding(Zend_Mime::ENCODING_BASE64)->setFrom($from)->addTo($address)->setSubject(mb_encode_mimeheader($subject, 'iso-2022-jp'))->setBodyText(mb_convert_encoding($body, 'JIS', 'UTF-8'), 'iso-2022-jp', Zend_Mime::ENCODING_7BIT);
     if ($envelopeFrom = sfConfig::get('op_mail_envelope_from')) {
         $mailer->setReturnPath($envelopeFrom);
     }
     $mailer->send($this->transport);
 }
Exemple #16
0
 function sendMail($user, $data)
 {
     $mail = new Zend_Mail('UTF-8');
     $mail->setHeaderEncoding(Zend_Mime::ENCODING_BASE64);
     $mail->setBodyHtml($data['message']);
     $mail->setFrom($data['from']);
     $mail->addTo($data['to'], $user['username']);
     $mail->setSubject($data['subject']);
     $mail->send();
 }
Exemple #17
0
 public function indexAction()
 {
     if ($this->_request->isPost()) {
         if ($this->input->hasInvalid()) {
             $missing = "";
             $notalnum = "";
             $message = "";
             foreach ($this->input->getInvalid() as $key => $value) {
                 if (isset($value["isEmpty"])) {
                     $missing .= $key . ",";
                 }
                 if (isset($value["notAlnum"])) {
                     $notalnum .= $key . ",";
                 }
             }
             if ($missing) {
                 $message .= "Following are required {$missing} \n";
             }
             if ($notalnum) {
                 $message .= "Following are alpha numeric only {$notalnum}";
             }
             throw new Zend_Service_Exception(Zend_Json::encode(array("error" => $message)));
         }
         if (!$this->_helper->csrf->isValidToken($this->token)) {
             throw new Zend_Service_Exception(Zend_Json::encode(array("error" => 'Token validation failed')));
         }
         if ($this->config->antispam) {
             switch ($this->config->antispam) {
                 case "typepad":
                     $spam = new Zend_Service_TypePadAntiSpam($this->config->typepad->key, "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
                     break;
                 case "akismet":
                     $spam = new Zend_Service_Akismet($this->config->akismet->key, "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
                     break;
             }
             if (isset($spam)) {
                 if ($spam->verifyKey()) {
                     $params = array();
                     $params["user_ip"] = $_SERVER['REMOTE_ADDR'];
                     $params["user_agent"] = $_SERVER['HTTP_USER_AGENT'];
                     $params["referrer"] = $_SERVER['HTTP_REFERER'];
                     $params["comment_type"] = "email";
                     $params["comment_author"] = $this->name;
                     $params["comment_author_email"] = $this->email;
                     $params["comment_content"] = $this->message;
                     if ($spam->isSpam($params)) {
                         throw new Zend_Service_Exception(Zend_Json::encode(array("error" => 'Message failed due to spam')));
                     }
                 }
             }
         }
         $mail = new Zend_Mail();
         $mail->setHeaderEncoding(Zend_Mime::ENCODING_BASE64);
         $mail->setBodyText($this->subject);
         $mail->setFrom($this->email, $this->name);
         $emails = explode(",", $this->to);
         $validator = new Zend_Validate_EmailAddress();
         foreach ($emails as $value) {
             if ($validator->isValid($value)) {
                 $mail->addTo($value);
             }
         }
         $mail->setSubject($this->subject);
         $mail->setBodyText($this->message);
         $mail->setBodyHtml($this->message);
         try {
             $mail->send();
         } catch (Exception $e) {
             throw new Zend_Service_Exception(Zend_Json::encode(array("error" => 'Mail send was not successful')));
         }
         $this->getResponse()->setBody(Zend_Json::encode(array("success" => "Message succesfully sent")));
     }
 }
Exemple #18
0
 public function recoverPasswordUser($email)
 {
     $db = Zend_Db_Table_Abstract::getDefaultAdapter();
     $select = $db->select()->from('users')->where("u_email='{$email}'");
     $stmp = $select->query();
     $res = $stmp->fetchAll();
     $password = $res[0]['u_password'];
     $body = "";
     $body .= "You have requested password recovery function<br/>";
     $body .= "Your password is: {$password}";
     $mail = new Zend_Mail('UTF-8');
     $mail->setHeaderEncoding(Zend_Mime::ENCODING_BASE64);
     $mail->setBodyHtml($body)->setFrom("*****@*****.**", "")->addTo($email)->setSubject("Password reminder");
     $mail->send();
 }
Exemple #19
0
 public static function execute($subject, $to, $from, $body)
 {
     if (!$to) {
         return false;
     }
     self::initialize();
     opApplicationConfiguration::registerZend();
     $subject = mb_convert_kana($subject, 'KV');
     $mailer = new Zend_Mail('iso-2022-jp');
     $mailer->setHeaderEncoding(Zend_Mime::ENCODING_BASE64)->setFrom($from)->addTo($to)->setSubject(mb_encode_mimeheader($subject, 'iso-2022-jp'))->setBodyText(mb_convert_encoding($body, 'JIS', 'UTF-8'), 'iso-2022-jp', Zend_Mime::ENCODING_7BIT);
     if ($envelopeFrom = sfConfig::get('op_mail_envelope_from')) {
         $mailer->setReturnPath($envelopeFrom);
     }
     try {
         $result = $mailer->send();
     } catch (Zend_Mail_Protocol_Exception $e) {
         if (sfContext::getInstance()->getActionName() === null) {
             error_log('Mail Send Error');
         } else {
             $action = sfContext::getInstance()->getActionStack()->getFirstEntry()->getActionInstance();
             $action->redirect('default/mailError');
         }
     }
     Zend_Loader::registerAutoLoad('Zend_Loader', false);
     return $result;
 }
Exemple #20
0
 /**
  * @group ZF-1688
  * @group ZF-2559
  */
 public function testSetHeaderEncoding()
 {
     $mail = new Zend_Mail();
     $this->assertEquals(Zend_Mime::ENCODING_QUOTEDPRINTABLE, $mail->getHeaderEncoding());
     $mail->setHeaderEncoding(Zend_Mime::ENCODING_BASE64);
     $this->assertEquals(Zend_Mime::ENCODING_BASE64, $mail->getHeaderEncoding());
 }
Exemple #21
0
 /**
  * Sends an email to a user
  *
  */
 public function mailtouserAction()
 {
     if ($this->_request->isPost()) {
         try {
             $config = $this->config;
             $user = $this->getUserByEmail($data['tomail']);
             $data = $this->_request->getParams();
             $mail = new Zend_Mail('UTF-8');
             $mail->setHeaderEncoding(Zend_Mime::ENCODING_BASE64);
             $mail->setBodyHtml($data['message']);
             $mail->setFrom('admin@' . $config->host->domain);
             $mail->addTo($data['tomail'], $user['username']);
             $mail->setSubject($data['subject']);
             //see if cc
             if (trim($data['cc'])) {
                 $mail->addCc($data['cc']);
             }
             $mail->send();
             $params = array("message" => $this->t("Mail Sent"), "msgtype" => 'success');
             $this->addMessage($params);
             $this->_helper->redirector('users', 'index', 'admin');
         } catch (Exception $e) {
             $params = array("message" => $this->t("Something went wrong"), "msgtype" => 'error');
             $this->addMessage($params);
             $this->_helper->redirector('users', 'index', 'admin');
         }
     } else {
         $params = array("message" => $this->t("Invalid Request"), "msgtype" => 'error');
         $this->addMessage($params);
         $this->_helper->redirector('users', 'index', 'admin');
     }
 }
 public static function execute($subject, $to, $from, $body)
 {
     if (!$to) {
         return false;
     }
     self::initialize();
     opApplicationConfiguration::registerZend();
     $subject = mb_convert_kana($subject, 'KV');
     $mailer = new Zend_Mail('iso-2022-jp');
     $mailer->setHeaderEncoding(Zend_Mime::ENCODING_BASE64)->setFrom($from)->addTo($to)->setSubject(mb_encode_mimeheader($subject, 'iso-2022-jp'))->setBodyText(mb_convert_encoding($body, 'JIS', 'UTF-8'), 'iso-2022-jp', Zend_Mime::ENCODING_7BIT);
     $result = $mailer->send();
     opApplicationConfiguration::unregisterZend();
     return $result;
 }
 /**
  * _compose constructs the email headers and body from the values extracted
  * from the submitted form and according to the mail configuration.
  *
  * @param Zend_Congig $config The mail configuration.
  *
  * @return Zend_Mail Instance of a Zend_Mail object.
  */
 private function _compose($config)
 {
     $mail = new Zend_Mail('UTF-8');
     $mail->setHeaderEncoding(Zend_Mime::ENCODING_BASE64);
     // Set mail subject
     $subject = mb_ereg_replace('\\$host', $_SERVER['HTTP_HOST'], $config->subject, 'i');
     $mail->setSubject($subject);
     if (array_key_exists('visitorName', $this->_rawVals)) {
         $this->visitorName = $this->_rawVals['visitorName'];
         unset($this->_rawVals['visitorName']);
     } else {
         $this->visitorName = $mail->getDefaultFrom['mail'];
     }
     if (array_key_exists('visitorEmail', $this->_rawVals)) {
         $this->visitorEmail = $this->_rawVals['visitorEmail'];
         unset($this->_rawVals['visitorEmail']);
     } else {
         $this->visitorEmail = $mail->getDefaultFrom['mail'];
     }
     if (array_key_exists('visitorMessage', $this->_rawVals)) {
         $this->visitorMessage = $this->_rawVals['visitorMessage'];
         unset($this->_rawVals['visitorMessage']);
     }
     if ($this->visitorEmail !== null && $this->visitorName !== null) {
         $mail->setFrom($this->visitorEmail, $this->visitorName);
         $mail->setReplyTo($this->visitorEmail, $this->visitorName);
     }
     $mail->setBodyText($this->visitorMessage, 'UTF-8', Zend_Mime::ENCODING_BASE64);
     return $mail;
 }