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 sendEmail($to, $body, $subject = "", $from = self::NO_REPLY_MAIL, $fromName = self::NO_REPLY_NAME, $replyTo = self::NO_REPLY_MAIL, $bcc = array(), $attachment = '') { $template_header = ''; $template_footer = ''; try { $mail = new sfMail(); $mail->initialize(); $mail->setMailer('sendmail'); $mail->setCharset('utf-8'); $mail->setContentType('text/html'); $mail->setSender($from, $fromName); $mail->setFrom($from, $fromName); $mail->addReplyTo($replyTo); $mail->addAddress($to); if (is_array($attachment)) { foreach ($attachment as $key => $row) { $mail->addAttachment($row); } } else { if ($attachment != '') { $mail->addAttachment($attachment); } } foreach ($bcc as $bcc_address) { $mail->addBcc($bcc_address); } $mail->setSubject($subject); $mail->setBody($template_header . $body . $template_footer); $mail->send(); return true; } catch (Exception $e) { return false; } }
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(); }
public function executeForget() { if ($this->getRequestParameter('email')) { $c = new Criteria(); $c->add(AdminPeer::EMAIL, $this->getRequestParameter('email')); $admin = AdminPeer::doSelectOne($c); if ($admin) { $template = MailTemplatePeer::retrieveByPK('__FORGET__'); $email = trim($admin->getEmail()); $subject = $template->getSubject(); $temp_body = $template->getTemplate(); $html_temp_body = $template->getHTMLTemplate(); $password = chr(rand(65, 90)) . chr(rand(65, 90)) . chr(rand(65, 90)) . chr(rand(65, 90)) . chr(rand(65, 90)); // random(ish) 5 character string $temp_body = str_replace('___PASSWORD___', $password, $temp_body); $html_temp_body = str_replace('___PASSWORD___', $password, $html_temp_body); $admin->setPassword(md5($password)); $admin->save(); $footer = MailTemplatePeer::retrieveByPK("FOOTER"); $temp_body .= $footer->getTemplate(); $html_temp_body .= $footer->getHTMLTemplate(); $mail = new sfMail(); $mail->initialize(); $mail->setMailer('sendmail'); $mail->setCharset('utf-8'); $mail->setSender('*****@*****.**'); $mail->addReplyTo('*****@*****.**'); $mail->setFrom('*****@*****.**'); $mail->setContentType('text/html'); $mail->addAddress($email); $mail->setSubject($subject); $mail->setBody($html_temp_body); $mail->setAltBody($temp_body); $mail->send(); $this->result = 'Thank you'; } else { $this->result = "we do not have user with this email"; } } }
public function sendMail($mailAddresses, $subject, $newsletterHtml) { $mail = new sfMail(); $mail->initialize(); $mail->setMailer('sendmail'); $mail->setCharset('utf-8'); $mail->setSender(UtilsHelper::NEWSLETTER_FROM_MAIL, UtilsHelper::SYSTEM_SENDER); $mail->setFrom(UtilsHelper::NEWSLETTER_FROM_MAIL, UtilsHelper::SYSTEM_SENDER); $mail->addAddress(UtilsHelper::NEWSLETTER_TO_MAIL); foreach ($mailAddresses as $mailAdd) { $mail->addBcc($mailAdd); } $mail->setContentType('text/html'); $mail->setSubject($subject); $mail->setBody($newsletterHtml); $mail->send(); }
function run_newsletter($task, $args) { ini_set("memory_limit", "2048M"); define('SF_ROOT_DIR', sfConfig::get('sf_root_dir')); define('SF_APP', 'frontend'); define('SF_ENVIRONMENT', 'prod'); define('SF_DEBUG', false); require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php'; /*$databaseManager = new sfDatabaseManager(); $databaseManager->initialize();*/ try { $controler = sfContext::getInstance()->getController(); $newsletterHtml = $controler->getPresentationFor("news", "composeNewsletter"); $newsletter = new Newsletter(); $today = UtilsHelper::DateBG(date('Y-m-d H:i:s', time()), 'd F, Y г.'); $newsletter->setLabel($today); $newsletter->setContent($newsletterHtml); $newsletter->save(); $mailinglist = Document::getDocumentByExclusiveTag("newsletter_mailinglist_default"); if ($mailinglist) { $subscribers = Document::getChildrenOf($mailinglist->getId(), "Subscriber"); } $subject = "Sgrada.com - ежедневен бюлетин"; $i = $ind = 0; $mailAddresses = array(); $cnt = count($subscribers); foreach ($subscribers as $subscriber) { $ind++; if ($subscriber->getPublicationStatus() == "ACTIVE") { $mailAddresses[] = $subscriber->getEmail(); echo " ====> " . $subscriber->getEmail() . "\n"; $i++; } if ($i == 100 || $ind == $cnt) { if (!empty($mailAddresses)) { //sendMail($mailAddresses, $subject, $newsletterHtml); $mail = new sfMail(); $mail->initialize(); $mail->setMailer('sendmail'); $mail->setCharset('utf-8'); $mail->setSender(UtilsHelper::NO_REPLY_MAIL, UtilsHelper::SYSTEM_SENDER); $mail->setFrom(UtilsHelper::NO_REPLY_MAIL, UtilsHelper::SYSTEM_SENDER); $mail->addAddress(UtilsHelper::NO_REPLY_MAIL); foreach ($mailAddresses as $mailAdd) { $mail->addBcc($mailAdd); } $mail->setContentType('text/html'); $mail->setSubject($subject); $mail->setBody($newsletterHtml); $mail->send(); } $mailAddresses = array(); $i = 0; } } } catch (Exception $e) { $newsletter->setLabel("ERROR! " . $today); $newsletter->save(); FileHelper::Log("TASK run_newsletter: " . $e->getMessage(), UtilsHelper::MSG_ERROR); } }
define('SF_APP', 'backend'); define('SF_ENVIRONMENT', 'prod'); define('SF_DEBUG', false); require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php'; $databaseManager = new sfDatabaseManager(); $databaseManager->initialize(); $c = new Criteria(); $c->add(BlogPeer::VERIFIED, true); $c->add(BlogPeer::APPROVED, false); $blogs = BlogPeer::doSelect($c); if (empty($blogs)) { return; } $mail = new sfMail(); $mail->initialize(); $mail->setMailer('sendmail'); $mail->setCharset('utf-8'); $mail->setSubject('Lista blogów do zatwierdzenia'); $mail->setSender('*****@*****.**', 'Planeta PHP.pl'); $mail->setFrom('*****@*****.**', 'Planeta PHP.pl'); $admins = AdminPeer::doSelect(new Criteria()); foreach ($admins as $admin) { $mail->addAddress($admin->getEmail()); } $body = "Oto lista blogów, które pozostały do zawierdzenia:\n"; foreach ($blogs as $blog) { $body .= " - {$blog->getName()} ({$blog->getUrl()})\n"; } $body .= "\nPanel administracyjny: http://planeta.php.pl/backend.php"; $mail->setBody($body); $mail->send();
public function executeResult() { $this->setLayout(false); if ($code = $this->getRequestParameter("codeid")) { $c = new Criteria(); $c->add(SubscriberPeer::CODE, $code); $user = SubscriberPeer::doSelectOne($c); if ($user) { $user->setPublicationStatus(UtilsHelper::STATUS_ACTIVE); //$user->setCode(null); $user->save(); $this->msg = "Subscribtion confirmed"; } else { $this->err = "A problem occured"; } return "Confirm"; } $email = trim($this->getRequestParameter('newsletter_email')); if (!empty($email)) { $new = false; $c = new Criteria(); $c->add(SubscriberPeer::EMAIL, $email); $c->add(SubscriberPeer::PUBLICATION_STATUS, UtilsHelper::STATUS_WAITING); $subscriber = SubscriberPeer::doSelectOne($c); if (!$subscriber) { $subscriber = new Subscriber(); $subscriber->setLabel($email); $subscriber->setEmail($email); $code = md5(time()); $subscriber->setCode($code); $new = true; } else { $code = $subscriber->getCode(); } $from_name = UtilsHelper::SYSTEM_SENDER; $from_email = UtilsHelper::NO_REPLY_MAIL; $mail = new sfMail(); $mail->initialize(); $mail->setMailer('sendmail'); $mail->setCharset('utf-8'); $mail->setSender($from_email, $from_name); $mail->setFrom($from_email, $from_name); $mail->addReplyTo($from_email); $mail->addAddress($email); $mail->addBcc(UtilsHelper::COPY_MAIL); $mail->setContentType('text/html'); $mail->setSubject('Newsletter subscribtion'); $resultPage = Document::getDocumentByExclusiveTag('website_page_newsletter_result'); if ($resultPage) { $resultPageHref = $resultPage->getHref(); } $request = $this->getRequest(); $request->setParameter('activationUrl', $resultPageHref . "?codeid=" . $code); $body = $this->getPresentationFor("newsletter", "confirmMail"); $mail->setBody($body); try { $mail->send(); $defMailinglist = Document::getDocumentByExclusiveTag('newsletter_mailinglist_default'); if ($defMailinglist && $new) { $subscriber->save(null, $defMailinglist); $subscriber->setPublicationStatus(UtilsHelper::STATUS_WAITING, true); } $this->msg = "Subscribtion successfull, check your email"; } catch (Exception $e) { $this->getRequest()->setError('newsletter_email', "A problem occured"); } } else { $this->getRequest()->setError('newsletter_email', "Please enter your email"); $this->form = true; } }
public function executeSendMailOnComment() { // Mail action cannot be called directly from the outside $this->forward404If($this->getController()->getActionStack()->getSize() == 1); sfLoader::loadHelpers(array('I18N')); $this->comment = $this->getRequest()->getAttribute('comment'); $mail = new sfMail(); $mail->setCharset('utf-8'); $mail->setSender('no-reply@' . $this->getRequest()->getHost()); $mail->setMailer('mail'); $mail->setFrom($mail->getSender(), sfConfig::get('app_sfSimpleBlog_title')); $mail->addAddresses(sfConfig::get('app_sfSimpleBlog_email')); if ($this->comment->getIsModerated()) { $subject_string = '[%1%] Please moderate: New comment on "%2%"'; } else { $subject_string = '[%1%] New comment on "%2%"'; } $mail->setSubject(__($subject_string, array('%1%' => sfConfig::get('app_sfSimpleBlog_title'), '%2%' => $this->comment->getPostTitle()))); $this->mail = $mail; }
public function executeContact() { //exit(UtilsHelper::Settings("main_email")); $this->setLayout(false); if ($this->getRequestParameter("submitted") == "submitted") { $request = $this->getRequest(); $params = $request->getParameterHolder()->getAll(); foreach ($params as $key => $param) { if (!is_array($param)) { ${$key} = trim($param); } else { ${$key} = $param; } } $mail = new sfMail(); $mail->initialize(); $mail->setMailer('sendmail'); $mail->setCharset('utf-8'); $mail->setContentType('text/html'); $mail->setFrom($email, $full_name); $mail->addAddress(UtilsHelper::Settings("main_email")); $mail->setSubject("Съобщение от {$cf_name}"); $mail->setSender($cf_email, $cf_name); $mail->setFrom($cf_email, $cf_name); $mail->addReplyTo($cf_email); //$serviceLabel = null; //$serviceObj = Document::getDocumentInstance($service); //if($serviceObj) $serviceLabel = $serviceObj->getLabel(); $msg = ""; $msg .= "Име: " . $cf_name . "\n" . ($msg .= "И-Мейл: " . $cf_email . "\n"); //$msg .= "Adress: ".$adress."\n"; //$msg .= "City: ".$city."\n"; //$msg .= "Zip Code: ".$zip."\n"; //$msg .= "State: ".$state."\n"; //if($home_phone) $message .= "Home Phone: ".$home_phone."\n"; //$msg .= "Cell Phone: ".$cell_phone."\n"; $msg .= "Съобщение: " . $cf_msg . "\n"; //$msg .= "Date of Opening: ".$date_open."\n"; //if($date_close) $msg .= "Date of Closing: ".$date_close."\n"; //if($serviceLabel) $msg .= "Service: ".$serviceLabel."\n"; $mail->setBody(nl2br($msg)); $mail->send(); //UtilsHelper::setFlashMsg( UtilsHelper::Localize("website.frontend.Sent"), UtilsHelper::MSG_SUCCESS); $this->success = true; } }