public function executeAddNewSubscriber(sfWebRequest $request) { $this->minyan = Utils::extractDomainObjectFromRequest($request, 'Minyan', 'minyanId', true); $this->form = new SignupForm(); unset($this->form['password']); if ($request->isMethod('post')) { $this->form->bind($request->getParameter('signup')); if ($this->form->isValid()) { $fields = $this->form->getValues(); $con = Doctrine::getConnectionByTableName('SfGuardUser'); try { $con->beginTransaction(); $this->logMessage("Executing signup for new user for minyan {$this->minyan->getName()}: {$fields['email']}", 'notice'); $sgu = new SfGuardUser(); $sgu->setFirstName($fields['first_name']); $sgu->setLastName($fields['last_name']); $sgu->setUsername($fields['email']); $sgu->setEmailAddress($fields['email']); $sgu->setPhone($fields['phone']); $sgu->setPassword(sfConfig::get('app_temp_password')); $sgu->setIsActive(true); $sgu->save(); $contactMethods = $request->getParameter('contact_method'); foreach ($contactMethods as $name => $method) { $contactMethods[$name] = Utils::toBoolean($method); } $minyanUser = new MinyanUser(); $minyanUser->setMinyanId($this->minyan->getId()); $minyanUser->setUserId($sgu->getId()); $minyanUser->setUsePhone($contactMethods['phone']); $minyanUser->setUseSms($contactMethods['text']); $minyanUser->setUseEmail($contactMethods['email']); $minyanUser->save(); $con->commit(); } catch (Exception $e) { $con->rollback(); $this->logMessage("Problem when signing up user {$fields['email']}: {$e->getMessage()}", 'notice'); throw $e; } MAMUtils::sendInternalEmail("New Make a Minyan User Alert for minyan {$this->minyan->getName()}! - {$sgu->getFullName()}", ""); //send email $options = array(); $options['template'] = 'welcomeToMinyan'; $options['subject'] = 'Welcome!'; $options['minyan'] = $this->minyan; $options['user'] = $sgu; $options['minyanUser'] = $minyanUser; $options['first_name'] = $sgu->getFirstName(); $options['to'] = $sgu->getUsername(); EmailUtils::send($options); $this->logMessage('Welcome email sent to ' . $sgu->getUsername(), 'notice'); $this->getUser()->setFlash('subscribersSuccess', 'Added ' . $sgu->getUsername() . ' successfully!'); echo Utils::ajaxResponse(true, $this->minyan->getId()); return sfView::NONE; } } }
function submit($email, $tweetStr) { $tweetUtils = new TweetsUtils(); $tweet = $tweetUtils->getMostRelevantTweet($tweetStr); if ($tweet->text == NULL) { return $tweet; } $email = new Email($email, "Tweet", createEmailBody($tweet)); if (EmailUtils::send($email)) { return $tweet; } return false; }
/** * Executes index action * * @param sfRequest $request A request object */ public function executeIndex(sfWebRequest $request) { $this->form = new SignupForm(); if ($request->isMethod('post')) { $this->form->bind($request->getParameter('signup')); if ($this->form->isValid()) { $fields = $this->form->getValues(); $con = Doctrine::getConnectionByTableName('SfGuardUser'); try { $con->beginTransaction(); $this->logMessage("Executing signup for new user: {$fields['email']}", 'notice'); $sgu = new SfGuardUser(); $sgu->setFirstName($fields['first_name']); $sgu->setLastName($fields['last_name']); $sgu->setUsername($fields['email']); $sgu->setEmailAddress($fields['email']); $sgu->setPhone($fields['phone']); $sgu->setPassword($fields['password']); $sgu->setIsActive(true); $sgu->save(); $con->commit(); } catch (Exception $e) { $con->rollback(); $this->logMessage("Problem when signing up user {$fields['email']}: {$e->getMessage()}", 'notice'); throw $e; } MAMUtils::sendInternalEmail("New Make a Minyan User Alert! - {$sgu->getFullName()}, Plan: {$this->plan['name']}", ""); //send email $options = array(); $options['template'] = 'welcome'; $options['subject'] = 'Welcome!'; $options['first_name'] = $sgu->getFirstName(); $options['to'] = $sgu->getUsername(); EmailUtils::send($options); $this->logMessage('Welcome email sent to ' . $sgu->getUsername(), 'notice'); $this->redirect('signup/thanks'); } } }
public static function createEmailResponse(BlastResponse $response) { Utils::logNotice('Sending email response for ' . $response->getBlast()->getMinyan()->getName() . ' to ' . $response->getUser()->getFullname() . ' (' . $response->getUser()->getUsername() . ')'); $blast = $response->getBlast(); //send email $options = array(); $options['template'] = 'blast'; $options['subject'] = 'Minyan Needed! ' . $blast->getEventType() . ' - ' . $blast->getMinyan()->getName(); $options['blastResponse'] = $response; $options['blast'] = $blast; $options['to'] = $response->getUser()->getUsername(); EmailUtils::send($options); }
public function testSendEmail() { $email = new Email('*****@*****.**', 'subject', $this->createEmailBody()); $this->assertTrue(EmailUtils::send($email)); }