当前位置: 首页>>代码示例>>PHP>>正文


PHP GeneralUtility::validEmail方法代码示例

本文整理汇总了PHP中TYPO3\CMS\Core\Utility\GeneralUtility::validEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP GeneralUtility::validEmail方法的具体用法?PHP GeneralUtility::validEmail怎么用?PHP GeneralUtility::validEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TYPO3\CMS\Core\Utility\GeneralUtility的用法示例。


在下文中一共展示了GeneralUtility::validEmail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isValid

 /**
  * @param Address $address
  * @return bool
  */
 protected function isValid($address)
 {
     $result = true;
     $settings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, 'H2dmailsub', 'Pidmailsubscribe');
     $validationSettings = $settings['validation'];
     foreach ($validationSettings as $field => $validations) {
         $value = $address->{'get' . ucfirst($field)}();
         foreach ($validations as $validation => $validationSetting) {
             switch ($validation) {
                 case 'required':
                     if ($validationSetting === '1' && empty($value)) {
                         $error = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Validation\\Error', \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('validation.required', 'h2dmailsub'), time());
                         $this->result->forProperty($field)->addError($error);
                         $result = false;
                     }
                     break;
                 case 'email':
                     if (!empty($value) && $validationSetting === '1' && !\TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($value)) {
                         $error = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Validation\\Error', \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('validation.email', 'h2dmailsub'), time());
                         $this->result->forProperty($field)->addError($error);
                         $result = false;
                     }
                     break;
             }
         }
     }
     return $result;
 }
开发者ID:HOCHZWEI,项目名称:h2dmailsub,代码行数:32,代码来源:SubscribeValidator.php

示例2: send

 /**
  * This is the main-function for sending Mails
  *
  * @param array $mailTo
  * @param array $mailFrom
  * @param string $subject
  * @param string $emailBody
  *
  * @return integer the number of recipients who were accepted for delivery
  */
 public function send($mailTo, $mailFrom, $subject, $emailBody)
 {
     if (!($mailTo && is_array($mailTo) && GeneralUtility::validEmail(key($mailTo)))) {
         $this->log->error('Given mailto email address is invalid.', $mailTo);
         return FALSE;
     }
     if (!($mailFrom && is_array($mailFrom) && GeneralUtility::validEmail(key($mailFrom)))) {
         $mailFrom = MailUtility::getSystemFrom();
     }
     /* @var $message \TYPO3\CMS\Core\Mail\MailMessage */
     $message = $this->objectManager->get('TYPO3\\CMS\\Core\\Mail\\MailMessage');
     $message->setTo($mailTo)->setFrom($mailFrom)->setSubject($subject)->setCharset(\TYPO3\T3extblog\Utility\GeneralUtility::getTsFe()->metaCharset);
     // send text or html emails
     if (strip_tags($emailBody) === $emailBody) {
         $message->setBody($emailBody, 'text/plain');
     } else {
         $message->setBody($emailBody, 'text/html');
     }
     if (!$this->settings['debug']['disableEmailTransmission']) {
         $message->send();
     }
     $logData = array('mailTo' => $mailTo, 'mailFrom' => $mailFrom, 'subject' => $subject, 'emailBody' => $emailBody, 'isSent' => $message->isSent());
     $this->log->dev('Email sent.', $logData);
     return $logData['isSent'];
 }
开发者ID:dextar1,项目名称:t3extblog,代码行数:35,代码来源:EmailService.php

示例3: isValid

 /**
  * return true if the element is valide
  *
  * @param	string $value value to test
  * @return	bool true if the element is valide
  */
 public function isValid($value)
 {
     if ($value == '') {
         return true;
     }
     return GeneralUtility::validEmail($value);
 }
开发者ID:ameos,项目名称:ameos_form,代码行数:13,代码来源:Email.php

示例4: validateAdditionalFields

 /**
  * Validates the additional fields' values
  *
  * @param array $submittedData An array containing the data submitted by the add/edit task form
  * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule Reference to the scheduler backend module
  * @return boolean TRUE if validation was ok (or selected class is not relevant), FALSE otherwise
  */
 public function validateAdditionalFields(array &$submittedData, SchedulerModuleController $schedulerModule)
 {
     $validInput = true;
     if (empty($submittedData[$this->fieldNames['time']])) {
         $schedulerModule->addMessage($GLOBALS['LANG']->sL($this->languageFile . 'error.empty'), FlashMessage::ERROR);
         $validInput = false;
     }
     try {
         $date = new \DateTime($submittedData[$this->fieldNames['time']]);
     } catch (\Exception $e) {
         $schedulerModule->addMessage($GLOBALS['LANG']->sL($this->languageFile . 'error.wrongFormat'), FlashMessage::ERROR);
         $validInput = false;
     }
     if (!empty($submittedData[$this->fieldNames['email']])) {
         $emails = GeneralUtility::trimExplode(';', $submittedData[$this->fieldNames['email']], true);
         foreach ($emails as $key => $email) {
             if (!GeneralUtility::validEmail($email)) {
                 $schedulerModule->addMessage($GLOBALS['LANG']->sL($this->languageFile . 'error.wrongEmail'), FlashMessage::ERROR);
                 $validInput = false;
                 break;
             }
         }
     }
     $validInput = $this->validateTestRunner($submittedData);
     return $validInput;
 }
开发者ID:sven-er,项目名称:disable_beuser,代码行数:33,代码来源:DisableBeuserAdditionalFields.php

示例5: isValid

 /**
  * Check if $value is valid. If it is not valid, needs to add an error
  * to result.
  *
  * @param mixed $value
  * @return void
  */
 public function isValid($value)
 {
     if (empty($value) || !is_string($value)) {
         return;
     }
     if (!GeneralUtility::validEmail($value)) {
         $this->addError($this->renderMessage($this->options['errorMessage'][0], $this->options['errorMessage'][1], 'error'), 1442000235);
     }
 }
开发者ID:dachcom-digital,项目名称:TYPO3.CMS,代码行数:16,代码来源:EmailValidator.php

示例6: isValid

 /**
  * Spam-Validation of given Params
  * 		see powermail/doc/SpamDetection for formula
  *
  * @param \In2code\Powermail\Domain\Model\Mail $mail
  * @return bool
  */
 public function isValid($mail)
 {
     if (!$this->settings['spamshield.']['_enable']) {
         return $this->getIsValid();
     }
     $spamFactor = $this->settings['spamshield.']['factor'] / 100;
     // Different checks to increase spam indicator
     $this->honeypodCheck($this->settings['spamshield.']['indicator.']['honeypod']);
     $this->linkCheck($mail, $this->settings['spamshield.']['indicator.']['link'], $this->settings['spamshield.']['indicator.']['linkLimit']);
     $this->nameCheck($mail, $this->settings['spamshield.']['indicator.']['name']);
     $this->sessionCheck($mail, $this->settings['spamshield.']['indicator.']['session']);
     $this->uniqueCheck($mail, $this->settings['spamshield.']['indicator.']['unique']);
     $this->blacklistStringCheck($mail, $this->settings['spamshield.']['indicator.']['blacklistString']);
     $this->blacklistIpCheck($this->settings['spamshield.']['indicator.']['blacklistIp']);
     // spam formula with asymptote 1 (100%)
     if ($this->spamIndicator > 0) {
         $thisSpamFactor = -1 / $this->spamIndicator + 1;
     } else {
         $thisSpamFactor = 0;
     }
     // Save Spam Factor in session for db storage
     $GLOBALS['TSFE']->fe_user->setKey('ses', 'powermail_spamfactor', $this->formatSpamFactor($thisSpamFactor));
     $GLOBALS['TSFE']->storeSessionData();
     // Spam debugging
     if ($this->settings['debug.']['spamshield']) {
         GeneralUtility::devLog('Spamshield (Spamfactor ' . $this->formatSpamFactor($thisSpamFactor) . ')', 'powermail', 0, $this->getMessages());
     }
     // if spam
     if ($thisSpamFactor >= $spamFactor) {
         $this->addError('spam_details', $this->formatSpamFactor($thisSpamFactor));
         $this->setIsValid(FALSE);
         // Send notification email to admin
         if (GeneralUtility::validEmail($this->settings['spamshield.']['email'])) {
             $subject = 'Spam in powermail form recognized';
             $message = 'Possible spam in powermail form on page with PID ' . $GLOBALS['TSFE']->id;
             $message .= "\n\n";
             $message .= 'Spamfactor of this mail: ' . $this->formatSpamFactor($thisSpamFactor) . "\n";
             $message .= "\n\n";
             $message .= 'Failed Spamchecks:' . "\n";
             $message .= Div::viewPlainArray($this->getMessages());
             $message .= "\n\n";
             $message .= 'Given Form variables:' . "\n";
             foreach ($mail->getAnswers() as $answer) {
                 $message .= $answer->getField()->getTitle();
                 $message .= ': ';
                 $message .= $answer->getValue();
                 $message .= "\n";
             }
             $header = 'MIME-Version: 1.0' . "\r\n";
             $header .= 'Content-type: text/html; charset=utf-8' . "\r\n";
             $header .= 'From: powermail@' . GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY') . "\r\n";
             GeneralUtility::plainMailEncoded($this->settings['spamshield.']['email'], $subject, $message, $header);
         }
     }
     return $this->getIsValid();
 }
开发者ID:advOpk,项目名称:pwm,代码行数:63,代码来源:SpamShieldValidator.php

示例7: evaluateFieldValue

 /**
  * Server valuation
  *
  * @param \string $value The field value to be evaluated.
  * @param \string $isIn The "isIn" value of the field configuration from TCA
  * @param \bool $set defining if the value is written to the database or not.
  * @return \string
  */
 public function evaluateFieldValue($value, $isIn, &$set)
 {
     if (GeneralUtility::validEmail($value)) {
         $set = 1;
     } else {
         $set = 0;
         $value = 'errorinemail@tryagain.com';
     }
     return $value;
 }
开发者ID:advOpk,项目名称:pwm,代码行数:18,代码来源:EvaluateEmail.php

示例8: isValid

 /**
  * Returns TRUE if submitted value validates according to rule
  *
  * @return bool
  * @see \TYPO3\CMS\Form\Validation\ValidatorInterface::isValid()
  */
 public function isValid()
 {
     if ($this->requestHandler->has($this->fieldName)) {
         $value = $this->requestHandler->getByMethod($this->fieldName);
         if (!\TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($value)) {
             return FALSE;
         }
     }
     return TRUE;
 }
开发者ID:plan2net,项目名称:TYPO3.CMS,代码行数:16,代码来源:EmailValidator.php

示例9: check

 public function check()
 {
     $checkFailed = '';
     if (isset($this->gp[$this->formFieldName]) && strlen(trim($this->gp[$this->formFieldName])) > 0) {
         $valid = \TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($this->gp[$this->formFieldName]);
         if (!$valid) {
             $checkFailed = $this->getCheckFailed();
         }
     }
     return $checkFailed;
 }
开发者ID:mhuebe,项目名称:formhandler,代码行数:11,代码来源:Tx_Formhandler_ErrorCheck_Email.php

示例10: sendEmailMessage

 /**
  * Sends an e-mail, if sender and recipient is an valid e-mail address
  *
  * @param string $sender The sender
  * @param string $recipient The recipient
  * @param string $subject The subject
  * @param string $body E-Mail body
  * @param string $name Optional sendername
  *
  * @return bool true/false if message is sent
  */
 public function sendEmailMessage($sender, $recipient, $subject, $body, $name)
 {
     if (GeneralUtility::validEmail($sender) && GeneralUtility::validEmail($recipient)) {
         $this->mail->setFrom($sender, $name);
         $this->mail->setSubject($subject);
         $this->mail->setBody($body, 'text/html');
         $this->mail->setTo($recipient);
         $this->mail->send();
         return $this->mail->isSent();
     } else {
         return false;
     }
 }
开发者ID:HOCHZWEI,项目名称:h2dmailsub,代码行数:24,代码来源:EmailService.php

示例11: getEmailsFromFeGroup

 /**
  * Read Emails from String
  *
  * @param int $uid fe_groups Uid
  * @return array Array with emails
  */
 protected static function getEmailsFromFeGroup($uid)
 {
     /** @var UserRepository $userRepository */
     $userRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(UserRepository::class);
     $users = $userRepository->findByUsergroup($uid);
     $array = [];
     foreach ($users as $user) {
         if (GeneralUtility::validEmail($user->getEmail())) {
             $array[] = $user->getEmail();
         }
     }
     return $array;
 }
开发者ID:abeyl,项目名称:powermail,代码行数:19,代码来源:StringUtility.php

示例12: getEmailsFromFeGroup

 /**
  * Read Emails from String
  *
  * @param int $uid fe_groups Uid
  * @return array Array with emails
  */
 protected static function getEmailsFromFeGroup($uid)
 {
     /** @var UserRepository $userRepository */
     $userRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager')->get('In2code\\Powermail\\Domain\\Repository\\UserRepository');
     $users = $userRepository->findByUsergroup($uid);
     $array = array();
     foreach ($users as $user) {
         if (GeneralUtility::validEmail($user->getEmail())) {
             $array[] = $user->getEmail();
         }
     }
     return $array;
 }
开发者ID:bernhardberger,项目名称:powermail,代码行数:19,代码来源:StringUtility.php

示例13: process

 function process(&$event, $email, $userId)
 {
     if ($email != '' && GeneralUtility::validEmail($email)) {
         $template = $this->conf['view.']['event.']['remind.'][$userId . '.']['template'];
         if (!$template) {
             $template = $this->conf['view.']['event.']['remind.']['all.']['template'];
         }
         $titleText = $this->conf['view.']['event.']['remind.'][$userId . '.']['emailTitle'];
         if (!$titleText) {
             $titleText = $this->conf['view.']['event.']['remind.']['all.']['emailTitle'];
         }
         $this->sendNotification($event, $email, $template, $titleText, '');
     }
 }
开发者ID:ulrikkold,项目名称:cal,代码行数:14,代码来源:ReminderView.php

示例14: sendEmailMessage

 /**
  * Sends an e-mail, if sender and recipient is an valid e-mail address
  *
  * @param string $sender The sender
  * @param string $recipient The recipient
  * @param string $subject The subject
  * @param string $body E-Mail body
  * @param string $name Optional sendername
  * @param array $attachments Array of files (e.g. ['/absolute/path/doc.pdf'])
  *
  * @return bool TRUE/FALSE if message is sent
  */
 public function sendEmailMessage($sender, $recipient, $subject, $body, $name = null, $attachments = [])
 {
     if (GeneralUtility::validEmail($sender) && GeneralUtility::validEmail($recipient)) {
         $this->initialize();
         $this->mailer->setFrom($sender, $name);
         $this->mailer->setSubject($subject);
         $this->mailer->setBody($body, 'text/html');
         $this->mailer->setTo($recipient);
         $this->addAttachments($attachments);
         $this->mailer->send();
         return $this->mailer->isSent();
     } else {
         return false;
     }
 }
开发者ID:derhansen,项目名称:sf_event_mgt,代码行数:27,代码来源:EmailService.php

示例15: validateAdditionalFields

 /**
  * Validates the additional fields' values
  *
  * @param array $submittedData An array containing the data submitted by the add/edit task form
  * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule Reference to the scheduler backend module
  * @return bool TRUE if validation was ok (or selected class is not relevant), FALSE otherwise
  */
 public function validateAdditionalFields(array &$submittedData, SchedulerModuleController $schedulerModule)
 {
     $validInput = true;
     $notificationEmails = GeneralUtility::trimExplode(LF, $submittedData[$this->fieldPrefix . 'NotificationEmail'], true);
     foreach ($notificationEmails as $notificationEmail) {
         if (!GeneralUtility::validEmail($notificationEmail)) {
             $validInput = false;
             break;
         }
     }
     if (empty($submittedData[$this->fieldPrefix . 'NotificationEmail']) || !$validInput) {
         $schedulerModule->addMessage($this->getLanguageService()->sL('LLL:EXT:reports/Resources/Private/Language/locallang_reports.xlf:status_updateTaskField_notificationEmails_invalid'), FlashMessage::ERROR);
         $validInput = false;
     }
     return $validInput;
 }
开发者ID:TYPO3Incubator,项目名称:TYPO3.CMS,代码行数:23,代码来源:SystemStatusUpdateTaskNotificationEmailField.php


注:本文中的TYPO3\CMS\Core\Utility\GeneralUtility::validEmail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。