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; }
public static function checkMessageData() { if (!EmailUtils::$_userName || !EmailUtils::$_userEmail || !EmailUtils::$_userMessage) { EmailUtils::getMessageData(); } if (empty(EmailUtils::$_userEmail)) { return EmailUtils::ERR_NO_EMAIL; } if (!is_email(EmailUtils::$_userEmail)) { return EmailUtils::ERR_WRONG_EMAIL; } if (empty(EmailUtils::$_userMessage)) { return EmailUtils::ERR_NO_MESSAGE; } return EmailUtils::ERR_SUCCESS; }
function addAction($data, $form) { if (!EmailUtils::validEmail($data['Email'])) { //Set error message $form->AddErrorMessage('Email', "That doesn't appear to be a valid email address.", 'bad'); //Set form data from submitted values Session::set("FormInfo.Form_CallForSpeakersRegistrationForm.data", $data); //Return back to form return Controller::curr()->redirectBack(); } // Set up session variables and forward to SpeakerDetails action // Find and load the talkID from the hidden field $TalkID = Convert::raw2sql($data['TalkID']); if (is_numeric($TalkID)) { Session::set('AddSpeakerProcess.TalkID', $TalkID); } Session::set('AddSpeakerProcess.Email', $data['Email']); Controller::curr()->redirect($form->controller()->Link() . 'SpeakerDetails/'); }
/** * 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'); } } }
<p>Here are your current settings: <br/> Email: <strong><?php echo $user->getUsername(); ?> </strong><br/> Phone: <strong><?php echo $user->getPhone(); ?> </strong><br/> Temporary Password: <strong><?php echo sfConfig::get('app_temp_password'); ?> </strong><br/> Contact Methods: <strong> <? if($minyanUser->getUsePhone()): ?> Phone <? endif; ?> <? if($minyanUser->getUseSms()): ?> Text <? endif; ?> <? if($minyanUser->getUseEmail()): ?> Email<? endif; ?> </strong> </p> <p>Don't hesitate to drop us a line or <a href="mailto:support@kishkee.com">send us an email</a> if you need something, we're here to help.</p> Now go to minyan!<br/> - The Abishter<br/> <? EmailUtils::emailFooter($options); ?>
/** * @internal Actual email dispatcher. * * @param type $subject Email subject value * @param type $to Email recipient value * @param type $txtbody Email text body value * @param type $htmlbody Email html body value * @param type $username Smtp username value * @param type $password Smtp username value * @param type $replyto Email replyto value * @param type $attachment Email attachment data * @param type $cc Email carbon copies * @param type $ext Email extended header data */ private static function sendEmail($subject, $to, $txtbody = '', $htmlbody = '', $username = null, $password = null, $replyto = false, $attachment = null, $cc = false, $ext = null) { if (EmailService::canUse()) { sendMultipartMail($subject, $to, $txtbody, $htmlbody, $username, $password, $replyto, $attachment, $cc, $ext); } else { EmailUtils::emailToLog($subject, $to, $txtbody, $htmlbody, $replyto, $cc, $ext); } }
/** * Returns TRUE if the given value passes validation. * * @param string $value A value to test * * @return boolean */ public function isValid($value) { if ($this->skipValidation) { return true; } $datatype = $this->validation['datatype']; //NULL check, empty strings are considered null if (in_array($datatype, array('string', 'url', 'email', 'slug', 'slugwithslash', 'html', 'binary', 'json')) && strlen(trim($value)) == 0) { $value = null; } if ($this->validation['nullable'] === false && $value === null && $datatype != 'boolean') { $this->failureCode = 'nullable'; $this->failureMessage = 'cannot be empty'; return false; } //Nothing more to validate if the value is null... if ($value === null) { return true; } //Check date makes sense if ($datatype === 'date') { //todo: not sure how to check validity of date... it's already a DateTime instance. if (false) { $this->failureCode = 'invalid'; $this->failureMessage = 'is an invalid date'; return false; } } //Validate MIN $min = $this->validation['min']; if ($min != null) { if ($datatype === 'float') { if ($value < floatval($min)) { $this->failureCode = 'min'; $this->failureMessage = 'is less than the minimum value'; return false; } } else { if ($datatype === 'int') { if ($value < intval($min)) { $this->failureCode = 'min'; $this->failureMessage = 'is less than the minimum value'; return false; } } else { if (is_string($value) && strlen($value) < intval($min)) { $this->failureCode = 'minlength'; $this->failureMessage = 'must be at least ' . $min . ' characters'; return false; } } } } //Validate MAX $max = $this->validation['max']; if ($max != null) { if ($datatype === 'float') { if ($value > floatval($max)) { $this->failureCode = 'max'; $this->failureMessage = 'is more than the maximum value'; return false; } } else { if ($datatype === 'int') { if ($value > intval($max)) { $this->failureCode = 'max'; $this->failureMessage = 'is more than the maximum value'; return false; } } else { $maxbytes = intval($max); if (intval($max) < 255) { // count characters if (is_string($value) && StringUtils::charCount($value) > intval($max)) { $this->failureCode = 'maxlength'; $this->failureMessage = 'must be a maximum of ' . $max . ' characters'; return false; } $maxbytes = 255; } // count bytes if (is_string($value) && StringUtils::byteCount($value) > intval($maxbytes)) { $this->failureCode = 'maxlength'; $this->failureMessage = 'must be a maximum of ' . $maxbytes . ' bytes'; return false; } } } } if ($datatype === 'slug') { if (!SlugUtils::isSlug($value, false)) { $this->failureCode = 'invalid'; $this->failureMessage = 'is not a valid slug, cannot contain slashes'; return false; } } if ($datatype === 'slugwithslash') { if (!SlugUtils::isSlug($value, true)) { $this->failureCode = 'invalid'; $this->failureMessage = 'is not a valid slug'; return false; } } if ($datatype === 'url') { if (!URLUtils::isUrl($value)) { $this->failureCode = 'invalid'; $this->failureMessage = 'is not a valid URL'; return false; } } if ($datatype === 'email') { if (!EmailUtils::isEmailAddress($value)) { $this->failureCode = 'invalid'; $this->failureMessage = 'is not a valid email address'; return false; } } if ($datatype === 'json') { if (!JSONUtils::isValid($value)) { $this->failureCode = 'invalid'; $this->failureMessage = 'is not a valid json string'; return false; } } //Validate MATCH expression $match = $this->validation['match']; if ($match != null) { // Automatically escape unescaped slashes in the match before running it $match = preg_replace('/([^\\\\])\\//', '$1\\/', $match); if (preg_match('/' . $match . '/s', $value) === 0) { $this->failureCode = 'invalid'; //$this->failureMessage = 'is invalid (' . substr($value, 0, 255) . ')'; $this->failureMessage = 'is invalid'; return false; } } // Validate all custom functions foreach ($this->validation['callback'] as $callback) { if (!empty($callback) && call_user_func($callback, $value) === false) { $this->failureCode = $callback; $this->failureMessage = 'is invalid'; return false; } } return true; }
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)); }
<?php require_once __DIR__ . '/wp-load.php'; require_once ABSPATH . WPINC . '/lib/utils/class-email-utils.php'; require_once ABSPATH . WPINC . '/lib/utils/class-recaptcha-utils.php'; $checkMessageDataResult = EmailUtils::checkMessageData(); if ($checkMessageDataResult != EmailUtils::ERR_SUCCESS) { returnFromScript($checkMessageDataResult); } if (!ReCaptchaUtils::checkCaptcha()) { returnFromScript(ReCaptchaUtils::ERR_BOT_CHECK_FAILED); } $sendMessageResult = EmailUtils::sendMessage(); returnFromScript($sendMessageResult); function returnFromScript($response) { exit($response); }