本文整理汇总了PHP中Zend\Validator\EmailAddress::isValid方法的典型用法代码示例。如果您正苦于以下问题:PHP EmailAddress::isValid方法的具体用法?PHP EmailAddress::isValid怎么用?PHP EmailAddress::isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Validator\EmailAddress
的用法示例。
在下文中一共展示了EmailAddress::isValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}
}
示例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");
}
示例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);
}
示例5: 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;
}
示例6: validate
/**
* Validates the mail-address using Zend.
* @param string $value
* @throws InvalidArgumentException
*/
protected function validate($value)
{
parent::validate($value);
$validator = new EmailValidator();
if (!$validator->isValid($value)) {
throw new ErrorException("Email address '{$value}' is invalid!");
}
}
示例7: 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;
}
示例8: setEmail
function setEmail($email)
{
$validador = new EmailAddress();
if (!$validador->isValid($email)) {
throw new Exception("E-mail não e valido");
}
$this->email = $email;
}
示例9: 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);
}
示例10: 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');
}
示例11: 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]);
}
示例12: 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.');
}
}
示例13: 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]);
}
示例14: createAction
public function createAction()
{
$emailValidator = new EmailAddress();
$m = $this->message();
$priorityList = ['urgent', 'high', 'normal', 'low'];
$typeList = ['problem', 'incident', 'question', 'task'];
$m->show('[info]What is you subject?[/info]');
$subject = $this->getConsole()->readLine();
$m->show('[info]Type[/info]');
$select = new Select('Which type?', $typeList);
$type = $typeList[$select->show()];
$m->show('[info]What is your email?[/info]');
$email = $this->getConsole()->readLine();
$m->show('[info]What is your tags (separated by comma)?[/info]');
$tags = explode(',', $this->getConsole()->readLine());
$tags = array_map('trim', $tags);
while (empty($description)) {
$m->show('[info]What is your description[/info]');
$description = $this->getConsole()->readLine();
}
$m->show('[info]Priority[/info]');
$select = new Select('Which priority?', $priorityList);
$priority = $priorityList[$select->show()];
$extra = [];
if ($emailValidator->isValid($email)) {
$extra['requester'] = $email;
}
$extra['tags'] = is_array($tags) ? [] : $tags;
$extra['priority'] = $priority;
$extra['type'] = $type;
$e = new Ticket();
$e->setSubject($subject);
$e->setDescription($description);
$e->setExtraFields($extra);
$result = $this->client->create($e->getArrayCopy());
if ($result) {
$e->exchangeArray((new ObjectProperty())->extract($result->ticket));
return json_encode($e->getArrayCopy(), JSON_PRETTY_PRINT);
}
return 0;
}
示例15: detectIssues
/**
* Returns true if and only if issue detector algorithm found any, and
* getIssues() will return an array of issues.
*
* @return boolean
*/
public function detectIssues()
{
try {
$emailValidator = new EmailAddress(['domain' => TRUE]);
if (empty($this->email)) {
$this->issueType = self::ISSUE_TYPE_MISSING;
} elseif (!$emailValidator->isValid($this->email)) {
$this->issueType = self::ISSUE_TYPE_INVALID;
} elseif ($this->checkTemporaryEmail()) {
$this->issueType = self::ISSUE_TYPE_TEMPORARY;
} elseif ($this->checkMissingEmail()) {
$this->issueType = self::ISSUE_TYPE_MISSING;
}
if (!empty($this->issueType)) {
$this->issue = TRUE;
$this->addIssue($this->issueType);
}
return $this->issue;
} catch (\Exception $e) {
}
}