public function init() { $this->sessao_agenda = new Zend_Session_Namespace('sessao_agenda'); $modelBanco = new Application_Model_ConfigSendMail(); $dataBanco = $modelBanco->getConfig(1); if (count($dataBanco)) { define('EMAIL_SENDER_SIS', $dataBanco->snd_login); define('PASS_SENDER_SIS', $dataBanco->snd_senha); define('PORT_MAILER', $dataBanco->snd_port); define('SSL_PROTOCOL', $dataBanco->snd_ssl_protocolo); define('NAME_SENDER_CLIENT', $dataBanco->snd_nome); define('EMAIL_SENDER_CLIENT', $dataBanco->snd_email_envio); //email para a resposta define('SMTP_ACCOUNT', $dataBanco->snd_smtp); } }
public function configurarSmtpAction() { $post = $this->getRequest(); $modelSMTP = new Application_Model_ConfigSendMail(); $data = $modelSMTP->getConfig(1); if (count($data)) { $params_banco = array('id' => 1, 'nome' => $data->snd_nome, 'email' => $data->snd_email_envio, 'login' => $data->snd_login, 'senha' => $data->snd_senha, 'ssl' => $data->snd_ssl_protocolo, 'smtp' => $data->snd_smtp, 'port' => $data->snd_port); } else { $params_banco = array('id' => 1, 'nome' => null, 'email' => null, 'login' => null, 'senha' => null, 'ssl' => null, 'smtp' => null, 'port' => null); } $this->view->params = $params_banco; if ($post->isPost()) { $params = $post->getParams(); unset($params['controller']); unset($params['module']); if (array_count_values($params) >= count($params_banco)) { $config = $modelSMTP->setConfig($params); $this->view->params = $params; if ($config) { $this->view->message = "Configuração realizada com sucesso!"; $this->view->message_class = "success"; } else { $this->view->message = "Nenhum campo foi modificado!"; $this->view->message_class = "warning"; } } else { $this->view->message = "Todos os campos precisam ser preenchidos!"; $this->view->message_class = "danger"; } } }
public function setBody(array $arguments = array(), $assunto = 'MENSAGEM DE EMAIL') { //configuração servidor de envio $modelBanco = new Application_Model_ConfigSendMail(); $dataBanco = $modelBanco->getConfig(1); if (count($dataBanco)) { $this->email_sender_sis = $dataBanco->snd_login; $this->pass_sender_sis = $dataBanco->snd_senha; $this->port_mailer = $dataBanco->snd_port; $this->ssl_protocol = $dataBanco->snd_ssl_protocolo; $this->smtp_account = $dataBanco->snd_smtp; $this->email_sender_client = $dataBanco->snd_email_envio; $this->name_sender_client = $dataBanco->snd_nome; } else { $this->email_sender_sis = EMAIL_SENDER_SIS; $this->pass_sender_sis = PASS_SENDER_SIS; $this->port_mailer = PORT_MAILER; $this->ssl_protocol = SSL_PROTOCOL; $this->smtp_account = SMTP_ACCOUNT; $this->email_sender_client = EMAIL_SENDER_CLIENT; $this->name_sender_client = NAME_SENDER_CLIENT; } $layout = $arguments['template'] ? $arguments['template'] : 'template_emkt.phtml'; $email_send = $this->email_sender_client; $email_receive = $arguments['email_recebe'] ? $arguments['email_recebe'] : $this->email_sender_client; $name_receive = $arguments['nome_recebe'] ? $arguments['nome_recebe'] : 'Usuário'; $text_receive = $arguments['dinamic_content'] ? $arguments['dinamic_content'] : '-'; $envia = array('email' => $email_send, 'nome' => $this->name_sender_client); $recebe = array('email' => $email_receive, 'nome' => $name_receive); $this->assunto = $assunto; $front_controller = Zend_Controller_Front::getInstance(); $request = new Zend_Controller_Request_Http(); $this->_baseUrl = $request->getBaseUrl(); $myView = new Zend_View(); $myView->addScriptPath(APPLICATION_PATH . '/views/scripts/templates/'); //$myView->addScriptPath($url.'/views/scripts/templates/'.$layout;); $html_body = $myView->render($layout); //substituí as tags pelo original $html_body = preg_replace('/{email}/', $email_receive, $html_body); $html_body = preg_replace('/{nome}/', $name_receive, $html_body); $html_body = preg_replace('/{texto_dinamico}/', $text_receive, $html_body); $html_body = preg_replace('/^<a(.*?)href=("|\')(.+)("|\')(.*?)>$/', '<a$1href=$2$3$2$5>', $html_body); preg_match_all('<a(.*?)href=("|\')([^"]+)("|\')(.*?)>', $html_body, $matches); if (count($matches)) { $arrayUrls = $matches[3]; $urls = array_values(array_filter($arrayUrls)); } if (count($urls)) { foreach ($urls as $k => $url) { $urlString = SITE_SUBFOLDER . '/index/click/k/' . str_replace('/', '::', base64_encode($email_receive)) . '/url/' . str_replace('/', '::', base64_encode(urlencode($url))); $urlString = $this->makeShortUrlBitly($urlString); $html_body = preg_replace('/<a(.*?)href=("|\')' . preg_quote($url, '/') . '("|\')(.*?)>/', '<a$1href=$2' . $urlString . '$2$5 mc:disable-tracking>', $html_body); } } // if(count($urls) ) { // foreach ($urls as $k => $url) { // // $urlString = SITE_SUBFOLDER.'/index/click/k/'.str_replace('/','::',base64_encode($email_receive)).'/url/'.str_replace('/','::',base64_encode(utf8_encode($url))); // $urlString = $this->makeShortUrlBitly($urlString); // // $html_body = preg_replace('/<a(.*?)href=("|\')'.preg_quote($url, '/').'("|\')(.*?)>/', '<a$1href=$2'.$urlString.'$2$5 mc:disable-tracking>', $html_body); // // $html_body = str_replace($url, $urlString, $html_body); // // } // } $html_body .= '<p>Se não deseja receber mais mensagens, <a href="' . $this->makeShortUrlBitly(SITE_SUBFOLDER . '/index/remover-email/k/' . str_replace('/', '::', base64_encode($email_receive))) . '" mc:disable-tracking>clique aqui</a>.</p>'; $this->enviaEmail = $envia; $this->recebeEmail = $recebe; $this->retornoEmail = $recebe; $this->html_body = $html_body; }