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


PHP Validator\EmailAddress类代码示例

本文整理汇总了PHP中Zend\Validator\EmailAddress的典型用法代码示例。如果您正苦于以下问题:PHP EmailAddress类的具体用法?PHP EmailAddress怎么用?PHP EmailAddress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __construct

 public function __construct()
 {
     $validatorEmail = new EmailAddress();
     $validatorEmail->setOptions(array('domain' => FALSE));
     $this->add(array('name' => 'email', 'filters' => array(array('name' => 'StringTrim'), array('name' => 'StripTags')), 'validators' => array($validatorEmail, array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'Digite corretamente o seu e-mail!'))))));
     $this->add(array('name' => 'senha', 'required' => true, 'filters' => array(array('name' => 'StringTrim'), array('name' => 'StripTags'))));
 }
开发者ID:RodrigoAngeloValentini,项目名称:curso-zf2,代码行数:7,代码来源:Login.php

示例2: queueNewMessage

 public function queueNewMessage($name, $email, $text, $html, $title, $prio = 1, $scheduleDate = null)
 {
     if (!isset($this->config['database']['entity'])) {
         throw new RuntimeException('No queue entity defined in the configuration.');
     }
     $validator = new EmailAddress();
     if (!$validator->isValid($email)) {
         throw new RuntimeException('Invalid recipient emailaddress');
     }
     if (!$validator->isValid($this->config['senderEmail'])) {
         throw new RuntimeException('Invalid sender emailaddress');
     }
     $entityName = $this->config['database']['entity'];
     $entity = new $entityName($this->entityManager);
     $entity->setPrio(intval($prio));
     $entity->setSend(0);
     $entity->setRecipientName((string) $name);
     $entity->setRecipientEmail((string) $email);
     $entity->setSenderName((string) $this->config['senderName']);
     $entity->setSenderEmail((string) $this->config['senderEmail']);
     $entity->setSubject((string) $title);
     $entity->setBodyHTML((string) $html);
     $entity->setBodyText((string) $text);
     $entity->setScheduleDate(get_class($scheduleDate) !== 'DateTime' ? new \DateTime() : $scheduleDate);
     $entity->setCreateDate(new \DateTime());
     $this->entityManager->persist($entity);
     $this->entityManager->flush();
     return $entity;
 }
开发者ID:milqmedia,项目名称:mq-mailqueue,代码行数:29,代码来源:SMTPAdapter.php

示例3: sendApplicantRejectionsAction

 public function sendApplicantRejectionsAction()
 {
     /**
      * @var \DDD\Service\Queue\EmailQueue $emailQueueService
      * @var \Mailer\Service\Email $mailer
      */
     $emailQueueService = $this->getServiceLocator()->get('service_queue_email_queue');
     $list = $emailQueueService->fetch(EmailQueue::TYPE_APPLICANT_REJECTION);
     if ($list && $list->count()) {
         /**
          * @var \DDD\Service\Textline $textlineService
          */
         $textlineService = $this->getServiceLocator()->get('service_textline');
         foreach ($list as $item) {
             //Don't send an email if applicant is not rejected anymore
             if (Applicant::APPLICANT_STATUS_REJECT != $item['status']) {
                 $emailQueueService->delete($item['id']);
                 continue;
             }
             $mailer = $this->getServiceLocator()->get('Mailer\\Email');
             $emailValidator = new EmailAddress();
             if (!$emailValidator->isValid($item['email'])) {
                 $this->outputMessage('[error] Applicant email is not valid: ' . $item['email'] . ' Removing from queue.');
                 $this->gr2err("Applicant rejection mail wasn't sent", ['applicant_id' => $item['entity_id'], 'applicant_name' => $item['applicant_name']]);
                 continue;
             }
             $mailer->send('applicant-rejection', ['to' => $item['email'], 'bcc' => EmailAliases::HR_EMAIL, 'to_name' => $item['applicant_name'], 'replyTo' => EmailAliases::HR_EMAIL, 'from_address' => EmailAliases::HR_EMAIL, 'from_name' => 'Ginosi Apartments', 'subject' => $textlineService->getUniversalTextline(1608, true), 'msg' => Helper::evaluateTextline($textlineService->getUniversalTextline(1607), ['{{APPLICANT_NAME}}' => $item['applicant_name'], '{{POSITION_TITLE}}' => $item['position_title']])]);
             $emailQueueService->delete($item['id']);
             $this->outputMessage("[1;32mRejection email to {$item['applicant_name']} sent. [0m");
         }
     } else {
         $this->outputMessage("[1;32mQueue is empty. [0m");
     }
     $this->outputMessage("[1;32mDone. [0m");
 }
开发者ID:arbi,项目名称:MyCode,代码行数:35,代码来源:EmailController.php

示例4: indexAction

 public function indexAction()
 {
     if (isset($_POST['username'])) {
         $data = [];
         $request = $this->getRequest();
         $username = $request->getPost('username');
         $age = $request->getPost('age');
         $emailAddress = $request->getPost('email');
         $digitsValidator = new Digits();
         $alphaValidator = new Alpha();
         $emailValidator = new EmailAddress();
         $data['age']['value'] = $age;
         $data['username']['value'] = $username;
         $data['email']['value'] = $emailAddress;
         if ($digitsValidator->isValid($age)) {
             $data['age']['message'] = 'Age = ' . $age . ' years old';
         } else {
             $data['age']['message'] = 'Age value invalid!';
         }
         if ($alphaValidator->isValid($username)) {
             $data['username']['message'] = 'Username = ' . $username;
         } else {
             $data['username']['message'] = 'Username value invalid!';
         }
         if ($emailValidator->isValid($emailAddress)) {
             $data['email']['message'] = 'Email Address = ' . $emailAddress;
         } else {
             $data['email']['message'] = 'Email Address value invalid!';
         }
         $data['message'] = 'success';
     }
     return new ViewModel($data);
 }
开发者ID:chrisbautista,项目名称:bcit-applied-development,代码行数:33,代码来源:IndexController.php

示例5: email

 /**
  *
  * @param string $subject Subject of mail message.
  * @param string $message Message of mail. Can contain HTML tags and spec symbols, for example "\n"
  * @param array|string $to If string and more one email, delimit by ',' (without spaces)
  * @param object $sl
  * @return boolean
  */
 public function email($subject, $message, $to, $sl)
 {
     try {
         $devMail = 'notify@ginosi.com';
         $emailValidator = new EmailAddress();
         $mailer = $sl->get('Mailer\\Email-Alerts');
         if (is_string($to) and strstr($to, ',')) {
             $to = preg_split("/(, |,)/", $to);
         } elseif (is_string($to)) {
             $to = [$to];
         }
         if (is_array($to)) {
             if (!in_array($devMail, $to)) {
                 array_push($to, $devMail);
             }
             foreach ($to as $key => $email) {
                 if (!$emailValidator->isValid($email)) {
                     unset($to[$key]);
                 }
             }
             if (empty($to)) {
                 return FALSE;
             }
             foreach ($to as $mailTo) {
                 $mailer->send('soother', array('layout' => 'clean', 'to' => $mailTo, 'from_address' => EmailAliases::FROM_MAIN_MAIL, 'from_name' => 'Ginosi Backoffice', 'subject' => $subject, 'message' => print_r($message, true)));
             }
         }
         return TRUE;
     } catch (\Exception $e) {
         return FALSE;
     }
 }
开发者ID:arbi,项目名称:MyCode,代码行数:40,代码来源:Email.php

示例6: setEmail

 function setEmail($email)
 {
     $validador = new EmailAddress();
     if (!$validador->isValid($email)) {
         throw new Exception("E-mail não e valido");
     }
     $this->email = $email;
 }
开发者ID:jonnathanvb,项目名称:stj,代码行数:8,代码来源:OrmLogin.php

示例7: validateValue

 /**
  * Value validator
  * @return $this
  * @throws ApplicationException
  */
 public function validateValue()
 {
     $validator = new EmailAddressValidator();
     if (!$validator->isValid($this->value)) {
         throw new ApplicationException(ApplicationException::IDENTITY_EMAIL_VALIDATION_FAILED);
     }
     return $this;
 }
开发者ID:ameteiko,项目名称:virgil-services-ra,代码行数:13,代码来源:Document.php

示例8: validateEmail

 /**
  * Trims and validates email
  * 
  * @param string $email
  * @return string
  * @throws Exception
  */
 public static function validateEmail($email)
 {
     $validator = new EmailAddress();
     if (!$validator->isValid((new StringTrim())->filter($email))) {
         throw new Exception(Json::encode($validator->getMessages()));
     }
     return $email;
 }
开发者ID:parnustk,项目名称:lisbackend,代码行数:15,代码来源:Validator.php

示例9: __construct

 public function __construct($name = null)
 {
     $hostNameValidator = new Validator\Hostname();
     $hostNameValidator->setMessages(array(Validator\Hostname::INVALID => "Неверный тип поля", Validator\Hostname::LOCAL_NAME_NOT_ALLOWED => "", Validator\Hostname::UNKNOWN_TLD => "Неопознанное имя хоста", Validator\Hostname::INVALID_HOSTNAME => "Некорректно задано имя хоста", Validator\Hostname::CANNOT_DECODE_PUNYCODE => "", Validator\Hostname::INVALID_DASH => "", Validator\Hostname::INVALID_HOSTNAME_SCHEMA => "", Validator\Hostname::INVALID_LOCAL_NAME => "", Validator\Hostname::INVALID_URI => "", Validator\Hostname::IP_ADDRESS_NOT_ALLOWED => "", Validator\Hostname::UNDECIPHERABLE_TLD => ""));
     $validator = new Validator\EmailAddress(array('hostnameValidator' => $hostNameValidator));
     $validator->setMessages(array(Validator\EmailAddress::INVALID => "Неверный тип поля", Validator\EmailAddress::INVALID_FORMAT => "Неверный формат поля. Используйте стандартный формат local-part@hostname", Validator\EmailAddress::INVALID_HOSTNAME => "'%hostname%' некорректное имя хоста для email адреса", Validator\EmailAddress::INVALID_LOCAL_PART => "'%localPart%' некорректное имя для email адреса", Validator\EmailAddress::LENGTH_EXCEEDED => "Значение превышает допустимые размеры поля", Validator\EmailAddress::INVALID_MX_RECORD => "", Validator\EmailAddress::INVALID_SEGMENT => "", Validator\EmailAddress::DOT_ATOM => "", Validator\EmailAddress::QUOTED_STRING => ""));
     $this->getValidatorChain()->attach($validator, true);
     parent::__construct($name);
 }
开发者ID:t4web,项目名称:base,代码行数:9,代码来源:Email.php

示例10: isValid

 public function isValid($value)
 {
     $messages = [];
     $result = true;
     $validator = new ZendEmailAddress();
     if (!$validator->isValid($value)) {
         $result = false;
         $messages[] = 'Must be a valid email address';
     }
     return new ValidatorResult($result, $messages);
 }
开发者ID:superdweebie,项目名称:validator,代码行数:11,代码来源:EmailAddress.php

示例11: getFormAction

 public function getFormAction()
 {
     $aRequest = $this->getRequest();
     $aPost = $aRequest->getPost();
     $sMail = $aPost['email'];
     $sSubject = $aPost['subject'];
     $validator = new Validator\EmailAddress();
     $validMessage = new Validator\NotEmpty();
     if (!$this->_validCaptcha($aPost['g-recaptcha-response'])) {
         return $this->redirect()->toRoute('contact');
     }
     if (!$validator->isValid($sMail)) {
         $this->flashMessenger()->addMessage($this->_getServTranslator()->translate("L'adresse e-mail renseignée n'est pas valide."), 'error');
         return $this->redirect()->toRoute('contact');
     }
     if (!$validMessage->isValid($aPost['message'])) {
         $this->flashMessenger()->addMessage($this->_getServTranslator()->translate("Votre message est vide."), 'error');
         return $this->redirect()->toRoute('contact');
     }
     $oViewModel = new ViewModel(array('post' => $aPost));
     $oViewModel->setTemplate('accueil/contact/mail_contact');
     $oViewModel->setTerminal(true);
     $sm = $this->getServiceLocator();
     $html = new MimePart(nl2br($sm->get('ViewRenderer')->render($oViewModel)));
     $html->type = "text/html";
     $body = new MimeMessage();
     $body->setParts(array($html));
     $oMail = new Message();
     $oMail->setBody($body);
     $oMail->setEncoding('UTF-8');
     $oMail->setFrom('contact@raid-tracker.com');
     $oMail->addTo('contact@raid-tracker.com');
     // $oMail->addCc('contact@raid-tracker.com');
     $oMail->setSubject($sSubject);
     $oSmtpOptions = new \Zend\Mail\Transport\SmtpOptions();
     $oSmtpOptions->setHost($this->_getServConfig()['mail']['auth'])->setConnectionClass('login')->setName($this->_getServConfig()['mail']['namelocal'])->setConnectionConfig(array('username' => $this->_getServConfig()['mail']['username'], 'password' => $this->_getServConfig()['mail']['password'], 'ssl' => $this->_getServConfig()['mail']['ssl']));
     $oSend = new \Zend\Mail\Transport\Smtp($oSmtpOptions);
     $bSent = true;
     try {
         $oSend->send($oMail);
     } catch (\Zend\Mail\Transport\Exception\ExceptionInterface $e) {
         $bSent = false;
         $this->flashMessenger()->addMessage($e->getMessage(), 'error');
     }
     if ($bSent) {
         $this->flashMessenger()->addMessage($this->_getServTranslator()->translate("Votre message a été envoyé."), 'success');
         $this->_getLogService()->log(LogService::NOTICE, "Email de {$sMail}", LogService::USER);
     } else {
         $this->flashMessenger()->addMessage($this->_getServTranslator()->translate("Votre message n'a pu être envoyé."), 'error');
         $this->_getLogService()->log(LogService::ERR, "Erreur d'envoie de mail à {$sMail}", LogService::USER);
     }
     return $this->redirect()->toRoute('contact');
 }
开发者ID:antarus,项目名称:mystra-pve,代码行数:53,代码来源:ContactController.php

示例12: sendAction

 public function sendAction()
 {
     $emailValidator = new EmailAddress();
     if (!$this->name or !$this->email or !$this->remarks) {
         echo 'error: need to fill in all params. see "ginosole --usage"' . PHP_EOL;
         return FALSE;
     } elseif (!$emailValidator->isValid($this->email)) {
         echo 'Error: Email not valid - ' . $this->email . PHP_EOL;
         return FALSE;
     }
     $serviceLocator = $this->getServiceLocator();
     $mailer = $serviceLocator->get('Mailer\\Email');
     $mailer->send('contact-us', ['layout' => 'clean', 'to' => EmailAliases::TO_CONTACT, 'to_name' => 'Ginosi Apartments', 'replyTo' => $this->email, 'from_address' => EmailAliases::FROM_MAIN_MAIL, 'from_name' => $this->name, 'subject' => 'Ginosi Apartments ✡ Contact Us ✡ From ' . $this->name, 'name' => $this->name, 'email' => $this->email, 'remarks' => $this->remarks]);
 }
开发者ID:arbi,项目名称:MyCode,代码行数:14,代码来源:ContactUsController.php

示例13: validateEntity

 /**
  * {@inheritDoc}
  */
 public function validateEntity(EntityInterface $entity, ErrorStore $errorStore)
 {
     if (false == $entity->getName()) {
         $errorStore->addError('o:name', 'The name cannot be empty.');
     }
     $email = $entity->getEmail();
     $validator = new EmailAddress();
     if (!$validator->isValid($email)) {
         $errorStore->addValidatorMessages('o:email', $validator->getMessages());
     }
     if (!$this->isUnique($entity, ['email' => $email])) {
         $errorStore->addError('o:email', sprintf('The email "%s" is already taken.', $email));
     }
     if (false == $entity->getRole()) {
         $errorStore->addError('o:role', 'Users must have a role.');
     }
 }
开发者ID:patrova,项目名称:omeka-s,代码行数:20,代码来源:UserAdapter.php

示例14: getInputFilter

 public function getInputFilter()
 {
     if ($this->filter == null) {
         $this->filter = new InputFilter();
         $inputFilter = parent::getInputFilter();
         $email = new Input('email');
         $email->setRequired(true);
         $email->setAllowEmpty(false);
         $objectExists = new ObjectExists(array('object_repository' => $this->objectManager->getRepository(User::getClass()), 'fields' => 'email'));
         $objectExists->setMessage($this->translator->translate('forgotPassword.email.notExists'), ObjectExists::ERROR_NO_OBJECT_FOUND);
         $emailAddress = new EmailAddress();
         $emailAddress->setMessage($this->translator->translate('forgotPassword.email.invalidFormat'), $emailAddress::INVALID_FORMAT);
         $email->getValidatorChain()->attach($emailAddress, true)->attach($objectExists);
         $this->filter->add($email);
     }
     return $this->filter;
 }
开发者ID:kristjanAnd,项目名称:SimpleIV,代码行数:17,代码来源:ForgotPassword.php

示例15: sendAction

 /**
  * @return JsonModel
  *
  * @throws \InvalidArgumentException
  */
 public function sendAction()
 {
     $projectId = $this->getEvent()->getRouteMatch()->getParam('project-id');
     $emailAddress = $this->getRequest()->getQuery()->get('email');
     $errorMessage = [];
     //Validate email address
     $validator = new EmailAddress();
     if (!$validator->isValid($emailAddress)) {
         $errorMessage[] = 'The email address is invalid';
     }
     if (is_null($projectId)) {
         $errorMessage[] = 'The projectId is empty';
     }
     $projectService = $this->getProjectService()->setProjectId($projectId);
     if (is_null($projectService)) {
         $errorMessage[] = 'The project cannot be found';
     }
     //Check if there is already an invite for this emailAddress
     foreach ($projectService->getProject()->getInvite() as $invite) {
         //When the invite is already taken we can resent it.
         if (!is_null($invite->getInviteContact())) {
             continue;
         }
         if (!is_null($invite->getDeeplink()->getDeeplinkContact())) {
             if ($emailAddress === $invite->getDeeplink()->getDeeplinkContact()->getContact()->getEmail()) {
                 $errorMessage[$emailAddress] = sprintf("Invitation to %s already sent", $emailAddress);
             }
         } else {
             if ($emailAddress === $invite->getDeeplink()->getCustom()->getEmail()) {
                 $errorMessage[$emailAddress] = sprintf("Invitation to %s already sent", $emailAddress);
             }
         }
     }
     if (sizeof($errorMessage) === 0) {
         $this->getInviteService()->inviteViaEmailAddress($projectService->getProject(), $emailAddress);
         //Re-load the $projectService;
         $this->getProjectService()->refresh();
         $this->getInviteService()->refresh();
         $renderer = $this->getServiceLocator()->get('ZfcTwigRenderer');
         $html = $renderer->render('project/partial/list/invitation', ['openInvites' => $this->getInviteService()->findOpenInvitesPerProject($projectService->getProject())]);
     } else {
         $html = implode("\n", $errorMessage);
     }
     return new JsonModel(['success' => sizeof($errorMessage) === 0, 'message' => $html]);
 }
开发者ID:debranova,项目名称:project,代码行数:50,代码来源:InviteController.php


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