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 executeSendPassword() { $mail = new sfMail(); $mail->addAddress($this->getRequestParameter('email')); $mail->setFrom('Askeet <*****@*****.**>'); $mail->setSubject('Askeet password recovery'); $mail->setPriority(1); $mail->addEmbeddedImage(sfConfig::get('sf_web_dir') . '/images/askeet_logo.gif', 'CID1', 'Askeet Logo', 'base64', 'image/gif'); $this->mail = $mail; $this->nickname = $this->getRequest()->getAttribute('nickname'); $this->password = $this->getRequest()->getAttribute('password'); }
public function executeSendPassword() { $mail = new sfMail(); $mail->addAddress($this->getRequestParameter('email')); $mail->setFrom('MetadataRegistry sysadmin <' . sfConfig::get('app_admin_email') . '>'); $mail->setSubject('Registry password recovery'); $mail->setPriority(1); //$mail->addEmbeddedImage(sfConfig::get('sf_web_dir').'/images/Registry_logo.gif', 'CID1', 'Registry Logo', 'base64', 'image/gif'); $this->mail = $mail; $this->nickname = $this->getRequest()->getAttribute('nickname'); $this->password = $this->getRequest()->getAttribute('password'); }
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 executeForgotPassword() { $email = $this->getRequest()->getAttribute('email'); $username = $this->getRequest()->getAttribute('username'); $password = $this->getRequest()->getAttribute('password'); $full_name = $this->getRequest()->getAttribute('full_name'); $mail = new sfMail(); $mail->setCharset('utf-8'); $mail->setSender('*****@*****.**', 'Hoydaa Snippets'); $mail->setFrom('*****@*****.**', 'Hoydaa Snippets'); $mail->addReplyTo('*****@*****.**'); $mail->setSubject('Hoydaa Snippets - Forgot Password'); $mail->addAddress($email); $this->mail = $mail; $this->username = $username; $this->password = $password; $this->full_name = $full_name; }
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 executeSendRegistrationConfirmation() { // determine customer from the request 'id' parameter $c = new Criteria(); $c->add(kuserPeer::ID, $this->getRequest()->getAttribute('id')); $user = kuserPeer::doSelectOne($c); if ($user && $user->getEmail() == $this->getRequest()->getAttribute('email')) { // class initialization $mail = new sfMail(); $mail->setCharset('utf-8'); // definition of the required parameters $mail->setSender('*****@*****.**', 'Kaltura Customer Service'); $mail->setFrom('*****@*****.**', 'Kaltura Customer Service'); $mail->addReplyTo('*****@*****.**'); $mail->addAddress($user->getEmail()); $mail->setSubject('Welcome to Kaltura!'); $this->name = $user->getScreenName(); $this->mail = $mail; } else { $this->getRequest()->setError('email', 'Problem while sending email'); $this->redirect('login/sendRegistrationConfirmation?error=Unknown'); } }
private static function signal() { $i18n = sfContext::getInstance()->getI18N(); // send an email for potential vandalism $email_recipient = UserPrivateData::find(108544)->getEmail(); // for now, topo-fr 108544 $email_subject = $i18n->__('Potential vandalism'); $server = $_SERVER['SERVER_NAME']; $module = self::$doc->getModule(); $link = "http://{$server}/{$module}/" . self::$doc->getId(); $htmlBody = $i18n->__('The document "%1%" has been potentially vandalised', array('%1%' => '<a href="' . $link . '">' . self::$doc->getCurrentI18nObject()->getName() . '</a>')); $mail = new sfMail(); $mail->setCharset('utf-8'); // definition of the required parameters $mail->setSender(sfConfig::get('app_outgoing_emails_sender')); $mail->setFrom(sfConfig::get('app_outgoing_emails_from')); $mail->addReplyTo(sfConfig::get('app_outgoing_emails_reply_to')); $mail->addAddress($email_recipient); $mail->setSubject($email_subject); $mail->setContentType('text/html'); $mail->setBody($htmlBody); $mail->setAltBody(strip_tags($htmlBody)); $mail->send(); }
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); } }
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; } }
/** * Executes "associate current document with document" action * associated document can only be : articles, summits, books, huts, outings, routes, sites, users * ... restricted in security.yml to logged people */ public function executeAddAssociation() { $user = $this->getUser(); $user_id = $user->getId(); $is_moderator = $user->hasCredential(sfConfig::get('app_credentials_moderator')); // // Get parameters and check that association is allowed // // if session is time-over if (!$user_id) { return $this->ajax_feedback('Session is over. Please login again.'); } if (!$this->hasRequestParameter('document_id') || !$this->hasRequestParameter('main_id') || !$this->hasRequestParameter('document_module')) { return $this->ajax_feedback('Operation not allowed'); } $main_module = $this->getRequestParameter('module'); $main_id = $this->getRequestParameter('main_id'); $linked_module = $this->getRequestParameter('document_module'); $linked_id = $this->getRequestParameter('document_id'); $icon = $this->getRequestParameter('icon', ''); $div = $this->getRequestParameter('div', false); if ($linked_id == $main_id) { return $this->ajax_feedback('A document can not be linked to itself'); } switch ($linked_module) { case 'summits': $fields = array('id', 'is_protected', 'summit_type'); break; case 'routes': $fields = array('id', 'is_protected', 'duration'); break; case 'huts': $fields = array('id', 'is_protected', 'shelter_type'); break; case 'articles': $fields = array('id', 'is_protected', 'article_type'); break; case 'images': $fields = array('id', 'is_protected', 'image_type'); break; case 'documents': $fields = array('id', 'is_protected', 'module'); break; // FIXME prevent such case? // FIXME prevent such case? default: $fields = array('id', 'is_protected'); break; } $linked_document = Document::find(c2cTools::module2model($linked_module), $linked_id, $fields); $linked_module = $linked_module != 'documents' ? $linked_module : $linked_document->get('module'); if (!$linked_document) { return $this->ajax_feedback('Linked document does not exist'); } $type_modules = c2cTools::Modules2Type($main_module, $linked_module); if (empty($type_modules)) { return $this->ajax_feedback('Wrong association type'); } list($type, $swap, $main_module_new, $linked_module_new, $strict) = $type_modules; switch ($main_module) { case 'summits': $fields = array('id', 'is_protected', 'summit_type'); break; case 'routes': $fields = array('id', 'is_protected', 'duration'); break; case 'huts': $fields = array('id', 'is_protected', 'shelter_type'); break; case 'articles': $fields = array('id', 'is_protected', 'article_type'); break; case 'images': $fields = array('id', 'is_protected', 'image_type'); break; case 'documents': $fields = array('id', 'is_protected', 'module'); break; // FIXME prevent such case? // FIXME prevent such case? default: $fields = array('id', 'is_protected'); break; } $main_document = Document::find(c2cTools::module2model($main_module), $main_id, $fields); if (!$main_document) { return $this->ajax_feedback('Main document does not exist'); } if ($swap) { $main_document_new = $linked_document; $main_id_new = $linked_id; $linked_document_new = $main_document; $linked_id_new = $main_id; } else { $main_document_new = $main_document; $main_id_new = $main_id; $linked_document_new = $linked_document; $linked_id_new = $linked_id; } if ($linked_module_new == 'articles') { if (!$is_moderator) { if ($linked_document_new->get('article_type') == 2 && !Association::find($user_id, $linked_id_new, 'uc')) { return $this->ajax_feedback('You do not have the right to link a document to a personal article'); } if ($main_module_new == 'articles') { if ($main_document_new->get('article_type') == 2 && !Association::find($user_id, $main_id_new, 'uc')) { return $this->ajax_feedback('You do not have the right to link a document to a personal article'); } } if ($main_module_new == 'outings' && !Association::find($user_id, $main_id_new, 'uo')) { return $this->ajax_feedback('You do not have the right to link an article to another user outing'); } } if ($linked_document_new->get('article_type') != 2 && $type == 'uc') { return $this->ajax_feedback('An user can not be linked to a collaborative article'); } } if ($linked_module_new == 'images') { if ($main_document_new->get('is_protected') && !$is_moderator) { return $this->ajax_feedback('Document is protected'); } if (!$is_moderator) { if ($main_module_new == 'users' && $main_id_new != $user_id) { return $this->ajax_feedback('You do not have the right to link an image to another user profile'); } if ($main_module_new == 'outings' && !Association::find($user_id, $main_id_new, 'uo')) { return $this->ajax_feedback('You do not have the right to link an image to another user outing'); } if ($main_module_new == 'articles' && $main_document_new->get('article_type') == 2 && !Association::find($user_id, $main_id_new, 'uc')) { return $this->ajax_feedback('You do not have the right to link an image to a personal article'); } if ($main_module_new == 'images' && $main_document_new->get('image_type') == 2 && $document->getCreatorId() != $user_id) { return $this->ajax_feedback('You do not have the right to link an image to a personal image'); } } } if ($linked_module_new == 'outings') { if (!$is_moderator) { if ($main_module_new == 'users' && !Association::find($user_id, $linked_id_new, 'uo')) { return $this->ajax_feedback('You do not have the right to link an user to another user outing'); } if ($main_module_new == 'routes' && !Association::find($user_id, $linked_id_new, 'uo')) { return $this->ajax_feedback('You do not have the right to link a route to another user outing'); } if ($main_module_new == 'sites' && !Association::find($user_id, $linked_id_new, 'uo')) { return $this->ajax_feedback('You do not have the right to link a site to another user outing'); } } } if ($linked_module_new == 'xreports') { if (!$is_moderator) { if ($main_module_new == 'users' && !Association::find($user_id, $linked_id_new, 'ux')) { return $this->ajax_feedback('You do not have the right to link an user to another user xreport'); } if ($main_module_new == 'outings' && !Association::find($user_id, $linked_id_new, 'ux')) { return $this->ajax_feedback('You do not have the right to link an outing to another user xreport'); } if ($main_module_new == 'routes' && !Association::find($user_id, $linked_id_new, 'ux')) { return $this->ajax_feedback('You do not have the right to link a route to another user xreport'); } if ($main_module_new == 'sites' && !Association::find($user_id, $linked_id_new, 'ux')) { return $this->ajax_feedback('You do not have the right to link a site to another user xreport'); } } } if ($linked_module_new == 'huts') { if ($main_module_new == 'summits') { $associations = Association::findAllAssociations($linked_id_new, 'sh'); if (count($associations)) { return $this->ajax_feedback('This hut is already linked to a summit'); } } if ($main_module_new == 'parkings') { $associations_pp = Association::findAllAssociations($main_id_new, 'pp'); $associations_ph = Association::findAllAssociations($linked_id_new, 'ph'); foreach ($associations_pp as $a_pp) { foreach ($associations_ph as $a_ph) { if ($a_pp['main_id'] == $a_ph['main_id'] || $a_pp['linked_id'] == $a_ph['main_id']) { return $this->ajax_feedback('A parking can not be linked to a hut if a main/sub parking is already linked to it'); } } } } } if ($linked_module_new == 'routes') { if ($main_module_new == 'summits' && $main_document_new->get('summit_type') == 5 && $linked_document_new->get('duration') <= 2) { return $this->ajax_feedback('A raid summit can not be linked to a stage route'); } if ($main_module_new == 'huts' && ($main_document_new->get('shelter_type') == 5 || $main_document_new->get('shelter_type') == 6)) { return $this->ajax_feedback('A gite can not be linked to a route'); } if ($main_module_new == 'parkings') { $associations_pp = Association::findAllAssociations($main_id_new, 'pp'); $associations_pr = Association::findAllAssociations($linked_id_new, 'pr'); foreach ($associations_pp as $a_pp) { foreach ($associations_pr as $a_pr) { if ($a_pp['main_id'] == $a_pr['main_id'] || $a_pp['linked_id'] == $a_pr['main_id']) { return $this->ajax_feedback('A parking can not be linked to a route if a main/sub parking is already linked to it'); } } } } } if ($linked_module_new == 'sites') { if ($main_module_new == 'sites') { if (Association::countAllMain(array($linked_id_new), 'tt')) { return $this->ajax_feedback('A sub site can not be linked to more than one main site'); } } if ($main_module_new == 'summits') { if (Association::countAllMain(array($linked_id_new), 'st')) { return $this->ajax_feedback('A site can not be linked to more than one summit'); } if (Association::countAllMain(array($linked_id_new), 'tt')) { return $this->ajax_feedback('A summit can not be linked to a sub site'); } } if ($main_module_new == 'parkings') { $associations_pp = Association::findAllAssociations($main_id_new, 'pp'); $associations_pt = Association::findAllAssociations($linked_id_new, 'pt'); foreach ($associations_pp as $a_pp) { foreach ($associations_pt as $a_pt) { if ($a_pp['main_id'] == $a_pt['main_id'] || $a_pp['linked_id'] == $a_pt['main_id']) { return $this->ajax_feedback('A parking can not be linked to a site if a main/sub parking is already linked to it'); } } } } } if ($linked_module_new == 'summits') { if ($main_module_new == 'summits') { if ($main_document_new->get('summit_type') == 5 || $linked_document_new->get('summit_type') == 5) { return $this->ajax_feedback('A raid summit can not be linked to a real summit'); } if (Association::countAllMain(array($linked_id_new), 'ss')) { return $this->ajax_feedback('A sub summit can not be linked to more than one main summit'); } } } if ($linked_module_new == 'parkings') { if ($main_module_new == 'parkings') { if (Association::countAllMain(array($linked_id_new), 'pp')) { // return $this->ajax_feedback('A sub parking can not be linked to more than one main parking'); } } } if (Association::find($main_id_new, $linked_id_new, $type, false)) { return $this->ajax_feedback('The document is already linked to the current document'); } if ($linked_module_new == 'outings' && $main_module_new == 'users' && $linked_id != $user_id) { // send an email to warn the new user associated $email_recipient = UserPrivateData::find($linked_id)->getEmail(); $email_subject = $this->__('You have been associated to an outing'); $server = $_SERVER['SERVER_NAME']; $outing_link = 'http' . (empty($_SERVER['HTTPS']) ? '' : 's') . "://{$server}/outings/{$main_id}"; $htmlBody = $this->__('You have been associated to outing %1% details', array('%1%' => '<a href="' . $outing_link . '">' . $outing_link . '</a>')); $mail = new sfMail(); $mail->setCharset('utf-8'); // definition of the required parameters $mail->setSender(sfConfig::get('app_outgoing_emails_sender')); $mail->setFrom(sfConfig::get('app_outgoing_emails_from')); $mail->addReplyTo(sfConfig::get('app_outgoing_emails_reply_to')); $mail->addAddress($email_recipient); $mail->setSubject($email_subject); $mail->setContentType('text/html'); $mail->setBody($htmlBody); $mail->setAltBody(strip_tags($htmlBody)); // send the email $mail->send(); } // Perform association $a = new Association(); $status = $a->doSaveWithValues($main_id_new, $linked_id_new, $type, $user_id); if (!$status) { return $this->ajax_feedback('Could not perform association'); } // cache clearing for current doc in every lang: $this->clearCache($main_module, $main_id, false, 'view'); $this->clearCache($linked_module, $linked_id, false, 'view'); // html to return sfLoader::loadHelpers(array('Tag', 'Url', 'Asset', 'AutoComplete')); $linked_document->setBestName($user->getPreferedLanguageList()); $bestname = $linked_document->get('name'); if ($linked_module == 'routes') { // in that case, output not only route name but also best summit name whose id has been passed (summit_id) $summit = explode(' [', $this->getRequestParameter('summits_name')); $bestname = $summit[0] . $this->__(' :') . ' ' . $bestname; } $linked_module_name = $icon ? $icon : $this->__($linked_module); $type_id_string = $type . '_' . $linked_id; $out = link_to($bestname, "@document_by_id?module={$linked_module}&id={$linked_id}"); if ($user->hasCredential('moderator')) { $out .= c2c_link_to_delete_element($type, $main_id_new, $linked_id_new, !$swap, $strict); } if ($div) { $icon_string = ''; if ($icon) { $icon_string = '<div class="assoc_img picto_' . $icon . '" title="' . ucfirst(__($icon)) . '">' . '<span>' . ucfirst(__($icon)) . __(' :') . '</span>' . '</div>'; } $out = '<div class="linked_elt" id="' . $type_id_string . '">' . $icon_string . $out . '</div>'; } else { $out = '<li id="' . $type_id_string . '">' . picto_tag('picto_' . $linked_module, $linked_module_name) . ' ' . $out . '</li>'; } return $this->renderText($out); }
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 executeNotifyModeratorsOnCommentWithLink() { $this->comment_object = $this->getRequest()->getAttribute('comment'); $env = sfConfig::get('sf_environment', 'prod'); $backend_controller = $env == 'prod' ? 'be.php' : "be_{$env}.php"; $this->comments_backend_url = 'http://' . sfConfig::get('sf_site_url') . "/{$backend_controller}/deppCommentingAdmin"; // do not send email if no news if (!$this->comment_object instanceof sfComment) { return sfView::NONE; } // mail class initialization $mail = new sfMail(); $mail->setCharset('utf-8'); $mail->setContentType('text/html'); // definition of the required parameters $mail->setSender(sfConfig::get('app_notifications_sender_address', '*****@*****.**'), sfConfig::get('app_notifications_from_tag', 'openparlamento')); $mail->setFrom(sfConfig::get('app_notifications_from_address', '*****@*****.**'), sfConfig::get('app_notifications_from_tag', 'openparlamento')); $moderators = array('*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**'); foreach ($moderators as $moderator) { $mail->addAddress($moderator); } // invia tutte le mail in BCC a un indirizzo di servizio $mail->addBcc('*****@*****.**'); $mail->setSubject("[openparlamento] nuovo commento contenente link"); $this->mail = $mail; }
public function doSaveWithValues($main_id, $linked_id, $type, $user_id) { $conn = sfDoctrine::Connection(); try { $conn->beginTransaction(); // we create the association: $this->main_id = $main_id; $this->linked_id = $linked_id; $this->type = $type; $this->save(); // and we log this: $al = new AssociationLog(); $al->main_id = $main_id; $al->linked_id = $linked_id; $al->type = $type; $al->user_id = $user_id; $al->is_creation = true; $al->save(); $conn->commit(); // send an email to moderators if a picture is associated to a book if ($type == 'bi') { try { // retrieve moderators email $moderator_id = sfConfig::get('app_moderator_user_id'); // currently send to topo-fr only $conn->beginTransaction(); $rows = $conn->standaloneQuery('SELECT email FROM app_users_private_data d WHERE id = ' . $moderator_id)->fetchAll(); $conn->commit(); $email_recipient = $rows[0]['email']; $mail = new sfMail(); $mail->setCharset('utf-8'); // definition of the required parameters $mail->setSender(sfConfig::get('app_outgoing_emails_sender')); $mail->setFrom(sfConfig::get('app_outgoing_emails_from')); $mail->addReplyTo(sfConfig::get('app_outgoing_emails_reply_to')); $mail->addAddress($email_recipient); $mail->setSubject('New image associated to book'); $mail->setContentType('text/html'); $server = $_SERVER['SERVER_NAME']; $body = "<p>A <a href=\"http://{$server}/images/{$linked_id}\">new image</a> has been associated to <a href=\"http://{$server}/books/{$main_id}\">book {$main_id}</a>.</p>" . "<p>The image may require a copyright license. If so, please ensure that:</p>" . "<ul>" . "<li>the owner is correctly acknowledged in the author field;</li>" . "<li>the image is not too big (max 800px width or height).</li>" . "</ul>"; $mail->setBody($body); // send the email $mail->send(); } catch (exception $e) { $conn->rollback(); c2cTools::log("Association::doSaveWithValues({$main_id}, {$linked_id}, {$type}, {$user_id}) failed sending email for image associated to book"); } } return true; } catch (exception $e) { $conn->rollback(); c2cTools::log("Association::doSaveWithValues({$main_id}, {$linked_id}, {$type}, {$user_id}) failed - rollback"); return false; } }
public function executeSendValidate() { $sfGuardUser = sfGuardUserPeer::retrieveByPK($this->getFlash('sfApplyPlugin_id', false)); if (!$sfGuardUser) { $this->logMessage('No user in executeSendValidate', 'err'); } $profile = $sfGuardUser->getProfile(); if (!$profile->getValidate()) { // Don't send a validation email unless they actually have // a validation code at the moment $this->logMessage('attempted executeSendValidate for a user with no validate code.', 'err'); return 'Error'; } $mail = new sfMail(); $mail->setCharset('utf-8'); $from = sfConfig::get('app_sfApplyPlugin_from'); if (!$from) { $this->logMessage('app_sfApplyPlugin_from is not set. Cannot send email.', 'err'); return 'Error'; } $this->validate = $profile->getValidate(); $vtype = self::getValidationType($this->validate); if ($vtype == 'Reset') { $mail->setSubject(sfConfig::get('app_sfApplyPlugin_reset_subject', "Please verify your password reset request on " . $this->getRequest()->getHost())); $this->logMessage('set reset subject', 'info'); } else { $mail->setSubject(sfConfig::get('app_sfApplyPlugin_apply_subject', "Please verify your account on " . $this->getRequest()->getHost())); $this->logMessage('set new subject', 'info'); } $mail->setSender($from['email'], $from['fullname']); $mail->setFrom($from['email'], $from['fullname']); $mail->addAddress($profile->getEmail(), $profile->getFullname()); $this->mail = $mail; $this->logMessage('returning from executeSendValidate', 'info'); return $vtype; }
protected function sendC2cEmail($module_name, $action_name, $email_subject, $email_recipient) { // Get message body $htmlBody = $this->getPresentationFor($module_name, $action_name); // class initialization $mail = new sfMail(); $mail->setCharset('utf-8'); // definition of the required parameters $mail->setSender(sfConfig::get('app_outgoing_emails_sender')); $mail->setFrom(sfConfig::get('app_outgoing_emails_from')); $mail->addReplyTo(sfConfig::get('app_outgoing_emails_reply_to')); $mail->addAddress($email_recipient); $mail->setSubject($email_subject); $mail->setContentType('text/html'); $mail->setBody($htmlBody); $mail->setAltBody(strip_tags($htmlBody)); // send the email $mail->send(); }
public function executeSendAlerts() { $user_id = $this->getRequestParameter('user_id'); $last_alert = $this->getRequestParameter('last_alert'); $this->user = OppUserPeer::retrieveByPK($user_id); $this->sf_site_url = sfConfig::get('sf_site_url', 'openparlamento'); $this->user_token = $this->user->getToken(); $this->user_alerts = oppAlertingTools::getUserAlerts($this->user, sfConfig::get('app_alert_max_results', 50), $last_alert); $this->n_alerts = OppAlertUserPeer::countUserAlerts($this->user); $this->n_total_notifications = oppAlertingTools::countTotalAlertsNotifications($this->user_alerts); // do not send email if no news if ($this->n_alerts == 0) { return sfView::NONE; } // mail class initialization $mail = new sfMail(); $mail->setCharset('utf-8'); $mail->setContentType('text/html'); // definition of the required parameters if ($this->user->isAdhoc()) { $mail->setSender(sfConfig::get('app_newsletter_pd_sender_address', '*****@*****.**'), sfConfig::get('app_newsletter_pd_from_tag', 'political desk')); $mail->setFrom(sfConfig::get('app_newsletter_pd_from_address', '*****@*****.**'), sfConfig::get('app_newsletter_pd_from_tag', 'political desk')); } else { $mail->setSender(sfConfig::get('app_newsletter_sender_address', '*****@*****.**'), sfConfig::get('app_newsletter_from_tag', 'openparlamento')); $mail->setFrom(sfConfig::get('app_newsletter_from_address', '*****@*****.**'), sfConfig::get('app_newsletter_from_tag', 'openparlamento')); } $mail->addAddress($this->user->getEmail()); // invia tutte le mail in BCC a un indirizzo di servizio if ($this->user->isAdhoc()) { $mail->addBcc('*****@*****.**'); } // alert utente espansi per il subject della mail $user_alerts_expanded = join(", ", array_map('extractTerm', array_slice($this->user_alerts, 0, 3))) . ($this->n_alerts > 3 ? ',...' : ''); $subj = sprintf("%d %s per %s che stai monitorando (%s) ", $this->n_total_notifications, $this->n_total_notifications == 1 ? 'avviso' : 'avvisi', $this->n_alerts == 1 ? 'il termine' : 'i ' . $this->n_alerts . ' termini', $user_alerts_expanded); $mail->setSubject($subj); $this->mail = $mail; }