ensure email is in the database
969764
def clean_email(self):
        
        if EMAIL_CONFIRMATION:
            from .models import EmailAddress
            condition = EmailAddress.objects.filter(
                email__iexact=self.cleaned_data["email"],
                verified=True
            ).count() == 0
        else:
            condition = User.objects.get(
                email__iexact=self.cleaned_data["email"],
                is_active=True
            ).count() == 0

        if condition is True:
            raise forms.ValidationError(
                _("Email address not verified for any user account")
            )
        return self.cleaned_data["email"]
437083
def validate_email(self, email_address):

        '''
            
        '''

        title = '%s.validate_email' % __class__.__name__

    # validate inputs
        object_title = '%s(email_address="")' % title
        email_address = self.fields.validate(email_address, '.email_address', object_title)

    # construct request_kwargs
        request_kwargs = {
            'url': '%s/address/validate' % self.api_endpoint,
            'params': { 'address': email_address }
        }

    # send request
        response_details = self._get_request(**request_kwargs)

        return response_details
564243
def _check_email_match(self, user, email):
        
        if user.email != email:
            # The passed email address doesn't match this username's email address.
            # Assume a problem and fail.
            raise CommandError(
                _(
                    'Skipping user "{}" because the specified and existing email '
                    'addresses do not match.'
                ).format(user.username)
            )
117168
public function thereAreNoUsersWithTheEmail($email)
    {
        $users = $this->getRepository()->getUserService()->loadUsersByEmail($email);
        Assertion::assertEquals(0, count($users), "Users with the email '$email' exist");
    }
562693
public function execute() {
        global $DB;

        // Generate new password emails for users - ppl expect these generated asap.
        if ($DB->count_records('user_preferences', array('name' => 'create_password', 'value' => '1'))) {
            mtrace('Creating passwords for new users...');
            $usernamefields = get_all_user_name_fields(true, 'u');
            $newusers = $DB->get_recordset_sql("SELECT u.id as id, u.email, u.auth, u.deleted,
                                                     u.suspended, u.emailstop, u.mnethostid, u.mailformat,
                                                     $usernamefields, u.username, u.lang,
                                                     p.id as prefid
                                                FROM {user} u
                                                JOIN {user_preferences} p ON u.id=p.userid
                                               WHERE p.name='create_password' AND p.value='1' AND
                                                     u.email !='' AND u.suspended = 0 AND
                                                     u.auth != 'nologin' AND u.deleted = 0");

            // Note: we can not send emails to suspended accounts.
            foreach ($newusers as $newuser) {
                // Use a low cost factor when generating bcrypt hash otherwise
                // hashing would be slow when emailing lots of users. Hashes
                // will be automatically updated to a higher cost factor the first
                // time the user logs in.
                if (setnew_password_and_mail($newuser, true)) {
                    unset_user_preference('create_password', $newuser);
                    set_user_preference('auth_forcepasswordchange', 1, $newuser);
                } else {
                    trigger_error("Could not create and mail new user password!");
                }
            }
            $newusers->close();
        }
    }
807188
function checkemail(next) {
      if (user.email) {
        userent.load$({ email: user.email }, function(err, userfound) {
          if (err) return done(err, { ok: false, user: user })
          if (userfound)
            return done(null, {
              ok: false,
              why: 'email-exists',
              nick: args.nick
            })
          next()
        })
        return
      }
      next()
    }
55597
def valid_email(emailaddress, domains=GENERIC_DOMAINS):
    """"""

    # Email address must be at least 6 characters in total.
    # Assuming noone may have addresses of the type a@com
    if len(emailaddress) < 6:
        return False  # Address too short.

    # Split up email address into parts.
    try:
        localpart, domainname = emailaddress.rsplit('@', 1)
        host, toplevel = domainname.rsplit('.', 1)
    except ValueError:
        return False  # Address does not have enough parts.

    # Check for Country code or Generic Domain.
    if len(toplevel) != 2 and toplevel not in domains:
        return False  # Not a domain name.

    for i in '-_.%+.':
        localpart = localpart.replace(i, "")
    for i in '-_.':
        host = host.replace(i, "")

    if localpart.isalnum() and host.isalnum():
        return True  # Email address is fine.
    else:
        return False
249209
def by_email_address(cls, email):
        """"""
        return DBSession.query(cls).filter_by(email_address=email).first()
191414
def activate():
    ''''''
    email = click.prompt('Email')
    user = User.objects(email=email).first()
    if not user:
        exit_with_error('Invalid user')
    if user.confirmed_at is not None:
        exit_with_error('User email address already confirmed')
        return
    user.confirmed_at = datetime.utcnow()
    user.save()
    success('User activated successfully')
1192998
function getEmailIfValid(emailToVerify) {
  if (emailToVerify) {
    const email = emailToVerify.trim();
    if (emailRegex.test(email)) {
      return email;
    } else {
      return undefined;
    }
  }
}
572573
def get_user_and_user_email_by_email(self, email):
        """"""
        if self.UserEmailClass:
            user_email = self.db_adapter.ifind_first_object(self.UserEmailClass, email=email)
            user = user_email.user if user_email else None
        else:
            user = self.db_adapter.ifind_first_object(self.UserClass, email=email)
            user_email = user
        return (user, user_email)
697418
function list_emails($default = false)
    {
        if ($this->emails === null) {
            $this->emails = array();

            $sql_result = $this->db->query(
                "SELECT `identity_id`, `name`, `email`"
                ." FROM " . $this->db->table_name('identities', true)
                ." WHERE `user_id` = ? AND `del` <> 1"
                ." ORDER BY `standard` DESC, `name` ASC, `email` ASC, `identity_id` ASC",
                $this->ID);

            while ($sql_arr = $this->db->fetch_assoc($sql_result)) {
                $this->emails[] = $sql_arr;
            }
        }

        return $default ? $this->emails[0] : $this->emails;
    }
409859
def set_email(self, email, _vars=None, lists=None, templates=None, verified=0, optout=None, send=None, send_vars=None):
        
        _vars = _vars or {}
        lists = lists or []
        templates = templates or []
        send_vars = send_vars or []
        data = {'email': email,
                'vars':  _vars.copy(),
                'lists': lists,
                'templates': templates,
                'verified': int(verified)}
        if optout is not None:
            data['optout'] = optout
        if send is not None:
            data['send'] = send
        if send_vars:
            data['send_vars'] = send_vars
        return self.api_post('email', data)
652324
protected function validateDataEmailStore()
    {
        $field = 'data.email';
        $value = $this->getSubmitted($field);
        $label = $this->translation->text('E-mail');

        if (empty($value)) {
            $this->setErrorRequired($field, $label);
            return false;
        }

        if (!is_array($value)) {
            $this->setErrorInvalid($field, $label);
            return false;
        }

        $filtered = array_filter($value, function ($email) {
            return filter_var($email, FILTER_VALIDATE_EMAIL);
        });

        if (count($value) != count($filtered)) {
            $this->setErrorInvalid($field, $label);
            return false;
        }

        return true;
    }
978844
def verifyEmails(emails=[], regExpPattern="^.+$"):
    
    emailsMatched = set()

    for i, e in enumerate(emails):
        if re.match(regExpPattern, e):
            emailsMatched.add(e)

    print(regExpPattern)

    return list(emailsMatched)
69275
def save_email(self, list_name, email_msg, index):
        """"""

        msg_id = email_msg.get('Message-ID')
        if not msg_id:
            return

        # Update last imported message into the DB
        mailinglist, created = MailingList.objects.get_or_create(
            name=list_name
        )
        mailinglist.last_imported_index = index

        if created:
            # if the mailinglist is newly created it's sure that the message
            #   is not in the DB yet.
            self.create_email(mailinglist, email_msg)

        else:
            # If the message is already at the database don't do anything
            try:
                Message.all_objects.get(
                    message_id=msg_id,
                    thread__mailinglist=mailinglist
                )

            except Message.DoesNotExist:
                self.create_email(mailinglist, email_msg)

        mailinglist.save()
144407
public function emailAddSendVerify($email_id, $iUserId = null)
    {
        //  Fetch the email and the user's group
        $oDb = Factory::service('Database');
        $oDb->select(
            [
                $this->tableEmailAlias . '.id',
                $this->tableEmailAlias . '.code',
                $this->tableEmailAlias . '.is_verified',
                $this->tableEmailAlias . '.user_id',
                $this->tableAlias . '.group_id',
            ]
        );

        if (is_numeric($email_id)) {
            $oDb->where($this->tableEmailAlias . '.id', $email_id);
        } else {
            $oDb->where($this->tableEmailAlias . '.email', $email_id);
        }

        if (!empty($iUserId)) {
            $oDb->where($this->tableEmailAlias . '.user_id', $iUserId);
        }

        $oDb->join(
            $this->table . ' ' . $this->tableAlias,
            $this->tableAlias . '.id = ' . $this->tableEmailAlias . '.user_id'
        );

        $oEmailRow = $oDb->get($this->tableEmail . ' ' . $this->tableEmailAlias)->row();

        if (!$oEmailRow) {
            $this->setError('Invalid Email.');
            return false;
        }

        if ($oEmailRow->is_verified) {
            $this->setError('Email is already verified.');
            return false;
        }

        // --------------------------------------------------------------------------

        $oEmailer                = Factory::service('Emailer', 'nails/module-email');
        $oEmail                  = new \stdClass();
        $oEmail->type            = 'verify_email_' . $oEmailRow->group_id;
        $oEmail->to_id           = $oEmailRow->user_id;
        $oEmail->data            = new \stdClass();
        $oEmail->data->verifyUrl = site_url('email/verify/' . $oEmailRow->user_id . '/' . $oEmailRow->code);

        if (!$oEmailer->send($oEmail, true)) {

            //  Failed to send using the group email, try using the generic email template
            $oEmail->type = 'verify_email';

            if (!$oEmailer->send($oEmail, true)) {
                //  Email failed to send, for now, do nothing.
                $this->setError('The verification email failed to send.');
                return false;
            }
        }

        return true;
    }