protected function enviarEmail() { $bug = $this->getRequestParameter('bug'); $mail = new sfMail(); $mail->initialize(); $mail->setMailer('smtp'); $mail->setHostname(sfConfig::get('app_smtp_server')); $mail->setPort(sfConfig::get('app_smtp_port')); $mail->setUsername(sfConfig::get('app_smtp_user')); $mail->setPassword(sfConfig::get('app_smtp_password')); $mail->setCharset('utf-8'); $mail->setContentType('text/html'); $mail->setSender($bug['email'], $bug['name']); $mail->setFrom($bug['email'], $bug['name']); $mail->addAddress(sfConfig::get('app_bugreport_mail_recipient')); $mail->setSubject(sfConfig::get('app_bugreport_mail_subject')); //$this->body = $this->getRequestParameter('message'); $cuerpo = sfConfig::get('app_bugreport_mail_txt_header'); $cuerpo .= "<br/>"; $cuerpo .= "url: " . $bug['url']; $cuerpo .= "<br/>"; $cuerpo .= $bug['description']; $cuerpo .= "<br/><br/>"; $cuerpo .= sfConfig::get('app_bugreport_mail_txt_footer'); $mail->setBody($cuerpo); $resultado = $mail->send(); return $resultado; }
public static function log500(sfEvent $event) { $exception = $event->getSubject(); $context = sfContext::getInstance(); //print_r($context); // is database configured? try { Propel::getConnection(); // log exception in db //$log = new sfErrorLog(); //$log->setType('sfError404Exception' == get_class($exception) ? 404 : 500); //$log->setClassName(get_class($exception)); //$log->setMessage(!is_null($exception->getMessage()) ? $exception->getMessage() : 'n/a'); //$log->setModuleName($context->getModuleName()); //$log->setActionName($context->getActionName()); //$log->setExceptionObject($exception); //$log->setRequest($context->getRequest()); //$log->setUri($context->getRequest()->getUri()); //$log->save(); // send email if (strtolower(SF_ENVIRONMENT) == "prod") { $mail = new sfMail(); $mail->initialize(); $mail->setMailer('smtp'); $mail->setHostname(sfConfig::get('app_smtp_server')); $mail->setPort(sfConfig::get('app_smtp_port')); $mail->setUsername(sfConfig::get('app_smtp_user')); $mail->setPassword(sfConfig::get('app_smtp_password')); $mail->setCharset('utf-8'); $mail->setContentType('text/html'); $mail->setFrom(sfConfig::get('app_email_default_address_from'), sfConfig::get('app_email_default_name_from')); $mail->addAddress(sfConfig::get('app_bugreport_mail_recipient1')); //$mail->addAddress(sfConfig::get('app_bugreport_mail_recipient2')); $mail->setSubject("Automatic: " . sfConfig::get('app_bugreport_mail_subject')); $cuerpo = "Type: 500<br />"; $cuerpo .= "Class: " . get_class($exception) . "<br />"; $cuerpo .= "Msg: " . (null !== $exception->getMessage()) ? $exception->getMessage() : 'n/a' . "<br />"; $cuerpo .= "Module: " . $context->getModuleName() . "<br />"; $cuerpo .= "Action: " . $context->getActionName() . "<br />"; $cuerpo .= "Uri: " . $context->getRequest()->getUri() . "<br />"; $cuerpo .= "Referer: " . $context->getRequest()->getReferer() . "<br />"; $cuerpo .= "Method: " . $context->getRequest()->getMethodName() . "<br />"; $cuerpo .= "Parameters: <br />"; foreach ($context->getRequest()->getParameterHolder()->getAll() as $key => $value) { $cuerpo .= " " . $key . ": " . $value . "<br />"; } $cuerpo .= "Cookies: " . $context->getRequest()->getHttpHeader('cookie') . "<br />"; $cuerpo .= "User Agent: " . $context->getRequest()->getHttpHeader('user-agent') . "<br />"; $cuerpo .= "Accept: " . $context->getRequest()->getHttpHeader('accept') . "<br />"; $cuerpo .= "Accept encoding: " . $context->getRequest()->getHttpHeader('accept-encoding') . "<br />"; $cuerpo .= "Accept language: " . $context->getRequest()->getHttpHeader('accept-language') . "<br />"; $cuerpo .= "Accept charset: " . $context->getRequest()->getHttpHeader('accept-charset') . "<br />"; $cuerpo .= "<br/><br/>"; $mail->setBody($cuerpo); $result = $mail->send(); } // end send email } catch (PropelException $e) { } }
public function sendmail($senderEmail, $senderName, $fromEmail, $fromName, $replyto, $to, $subject, $body) { $mail = new sfMail(); $mail->initialize(); $mail->setMailer(sfConfig::get('app_mail_server_type')); $mail->setHostname(sfConfig::get('app_mail_hostname')); $mail->setUsername(sfConfig::get('app_mail_username')); $mail->setPassword(sfConfig::get('app_mail_password')); $mail->setCharset(sfConfig::get('app_mail_character')); $mail->setSender($senderEmail, $senderName); $mail->setFrom($fromEmail, $fromName); $mail->addReplyTo($replyto); $mail->addAddress($to); $mail->setSubject($subject); $mail->setBody($body); $mail->send(); }