@param [String] api_key Mailgun API - public key
 Given an arbitrary address, validates it based on defined checks.

 @param [String] address Email address to validate (max 512 chars.)
483222
def validate(address, mailbox_verification = false)
      params = {:address => address}
      params[:mailbox_verification] = true if mailbox_verification

      res = @client.get "address/validate", params
      return res.to_h!
    end
1334347
def verify_email_for_object(self, email, content_object, email_field_name='email'):
        

        confirmation_key = generate_random_token()

        try:
            confirmation = EmailConfirmation()
            confirmation.content_object = content_object
            confirmation.email_field_name = email_field_name
            confirmation.email = email
            confirmation.confirmation_key = confirmation_key
            confirmation.save()
        except IntegrityError:
            confirmation = EmailConfirmation.objects.get_for_object(content_object, email_field_name)
            confirmation.email = email
            confirmation.confirmation_key = confirmation_key
            confirmation.save(update_fields=['email', 'confirmation_key'])

        confirmation.send()

        return confirmation
678650
public static function check_email($email, $dns_check=true)
    {
        // Check for invalid characters
        if (preg_match('/[\x00-\x1F\x7F-\xFF]/', $email)) {
            return false;
        }

        // Check for length limit specified by RFC 5321 (#1486453)
        if (strlen($email) > 254) {
            return false;
        }

        $email_array = explode('@', $email);

        // Check that there's one @ symbol
        if (count($email_array) < 2) {
            return false;
        }

        $domain_part = array_pop($email_array);
        $local_part  = implode('@', $email_array);

        // from PEAR::Validate
        $regexp = '&^(?:
            ("\s*(?:[^"\f\n\r\t\v\b\s]+\s*)+")|                             #1 quoted name
            ([-\w!\#\$%\&\'*+~/^`|{}=]+(?:\.[-\w!\#\$%\&\'*+~/^`|{}=]+)*))  #2 OR dot-atom (RFC5322)
            $&xi';

        if (!preg_match($regexp, $local_part)) {
            return false;
        }

        // Validate domain part
        if (preg_match('/^\[((IPv6:[0-9a-f:.]+)|([0-9.]+))\]$/i', $domain_part, $matches)) {
            return self::check_ip(preg_replace('/^IPv6:/i', '', $matches[1])); // valid IPv4 or IPv6 address
        }
        else {
            // If not an IP address
            $domain_array = explode('.', $domain_part);
            // Not enough parts to be a valid domain
            if (count($domain_array) < 2) {
                return false;
            }

            foreach ($domain_array as $part) {
                if (!preg_match('/^((xn--)?([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]))$/', $part)) {
                    return false;
                }
            }

            // last domain part
            $last_part = array_pop($domain_array);
            if (strpos($last_part, 'xn--') !== 0 && preg_match('/[^a-zA-Z]/', $last_part)) {
                return false;
            }

            $rcube = rcube::get_instance();

            if (!$dns_check || !function_exists('checkdnsrr') || !$rcube->config->get('email_dns_check')) {
                return true;
            }

            // Check DNS record(s)
            // Note: We can't use ANY (#6581)
            foreach (array('A', 'MX', 'CNAME', 'AAAA') as $type) {
                if (checkdnsrr($domain_part, $type)) {
                    return true;
                }
            }
        }

        return false;
    }
646920
def update(address, new_address, options={})
      params = {:address => new_address}
      Mailgun.submit :put, list_url(address), params.merge(options)
    end
72140
def _validate_simple(email):
        
        name, address = parseaddr(email)
        if not re.match('[^@]+@[^@]+\.[^@]+', address):
            raise ValueError('Invalid email :{email}'.format(email=email))
        return address
955830
def validate_options(options)
        options = options ? Hash[options] : {}
        options[:mailbox] ||= 'INBOX'
        options[:count]   ||= 10
        options[:order]   ||= :asc
        options[:what]    ||= :first
        options[:keys]    ||= 'ALL'
        options[:uid]     ||= nil
        options[:delete_after_find] ||= false
        options[:mailbox] = Net::IMAP.encode_utf7(options[:mailbox])
        options[:read_only] ||= false

        options
      end
430143
def validate
    ['from', 'to'].each do |s|
      raise Error, "'#{s}' must be a valid IMAP URI (e.g. imap://example.com)" unless fetch(s) =~ IMAP::REGEX_URI
    end

    unless Logger::LEVELS.has_key?(verbosity.to_sym)
      raise Error, "'verbosity' must be one of: #{Logger::LEVELS.keys.join(', ')}"
    end

    if exclude_file
      raise Error, "exclude file not found: #{exclude_file}" unless File.file?(exclude_file)
      raise Error, "exclude file cannot be read: #{exclude_file}" unless File.readable?(exclude_file)
    end

    if @cached['all'] || @cached['all-subscribed']
      # A specific source folder wins over 'all' and 'all-subscribed'
      if @cached['from-folder']
        @cached['all']              = false
        @cached['all-subscribed']   = false
        @cached['to-folder']      ||= @cached['from-folder']

      elsif @cached['all'] && @cached['all-subscribed']
        # 'all' wins over 'all-subscribed'
        @cached['all-subscribed'] = false
      end

      # 'no-recurse' is not compatible with 'all' and 'all-subscribed'
      raise Error, "'no-recurse' option cannot be used with 'all' or 'all-subscribed'" if @cached['no-recurse']

    else
      @cached['from-folder'] ||= 'INBOX'
      @cached['to-folder']   ||= 'INBOX'
    end

    @cached['exclude'].flatten!
  end
550235
def validate_email(email):
    
    from django.core.validators import validate_email
    from django.core.exceptions import ValidationError
    try:
        validate_email(email)
        return True
    except ValidationError:
        return False
178217
def authenticate_key(api_key):
    
    user_model = Query()
    user = db.search(user_model.api_key == api_key)[0]
    if user:
        return user['username']
    return False
86832
def recipient_name=(v)
      @recipient_name = nil
      if (v = sanitize(v)) && v.length > 0
        @recipient_name = v
      else
        raise USPSValidationError, "'#{v}' is not a valid string in #{__method__}"
      end
    end
1369747
def api_send_mail(request, key=None, hproPk=None):
    """"""

    if not check_api_key(request, key, hproPk):
        return HttpResponseForbidden

    sender = request.POST.get('sender', settings.MAIL_SENDER)
    dests = request.POST.getlist('dests')
    subject = request.POST['subject']
    message = request.POST['message']
    html_message = request.POST.get('html_message')

    if html_message and html_message.lower() == 'false':
        html_message = False

    if 'response_id' in request.POST:
        key = hproPk + ':' + request.POST['response_id']
    else:
        key = None

    generic_send_mail(sender, dests, subject, message, key, 'PlugIt API (%s)' % (hproPk or 'StandAlone',), html_message)

    return HttpResponse(json.dumps({}), content_type="application/json")
1232205
def add_webhook_identifier_to_email(email)
			email.message.mailgun_variables = {}
        	email.message.mailgun_variables["webhook_identifier"] = BSON::ObjectId.new.to_s
        	email
		end
13567
function Connector(settings) {
    this.mailgun = Mailgun({apiKey: settings.apikey, domain: settings.domain});
}
228534
def email_verifier(self, email, raw=False):
        
        params = {'email': email, 'api_key': self.api_key}

        endpoint = self.base_endpoint.format('email-verifier')

        return self._query_hunter(endpoint, params, raw=raw)
1014045
def pre_populate_buyer_email=(pre_populate_buyer_email)

      if !pre_populate_buyer_email.nil? && pre_populate_buyer_email.to_s.length > 254
        fail ArgumentError, "invalid value for 'pre_populate_buyer_email', the character length must be smaller than or equal to 254."
      end

      @pre_populate_buyer_email = pre_populate_buyer_email
    end
191528
def _map_smtp_headers_to_api_parameters(self, email_message):
        
        api_data = []
        for smtp_key, api_transformer in six.iteritems(self._headers_map):
            data_to_transform = email_message.extra_headers.pop(smtp_key, None)
            if data_to_transform is not None:
                if isinstance(data_to_transform, (list, tuple)):
                    # map each value in the tuple/list
                    for data in data_to_transform:
                        api_data.append((api_transformer[0], api_transformer[1](data)))
                elif isinstance(data_to_transform, dict):
                    for data in six.iteritems(data_to_transform):
                        api_data.append(api_transformer(data))
                else:
                    # we only have one value
                    api_data.append((api_transformer[0], api_transformer[1](data_to_transform)))
        return api_data
589484
def email_verification_email(token, root_url)
    @token = token
    @protocol, @host = *root_url.split('://', 2)
    @host.slice!(-1) if @host[-1] == ?/
    hostname = @host.split(':', 2).first  # Strip out any port.

    mail to: @token.email,
         subject: email_verification_subject(token, hostname, @protocol),
         from: email_verification_from(token, hostname, @protocol)
  end