Skip to content

Email Functions

Basic email testing

This module needs building out further, but at the moment can test if the syntax of a given email address is correct.

Classes:

Name Description
EmailFunctions

placeholder

EmailFunctions

Source code in app/dcsp/app/functions/email_functions.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class EmailFunctions:
    _valid_email_regex: str = (
        r"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b"
    )

    def __init__(self) -> None:
        """Init

        Nothing is done in the initialisation phase
        """
        return

    def valid_syntax(self, email: str) -> bool:
        """Checks if the syntax of an email string is corrent

        This function only checks if the syntax of an email is correct. It does
        not confirm if the email exists or that the end-server is able to
        process the email

        Args:
            email (str): the email address to be assesed.

        Returns:
            bool: True if a valid email, otherwise False.
        """
        if re.fullmatch(self._valid_email_regex, email):
            return True

        else:
            return False

__init__()

Init

Nothing is done in the initialisation phase

Source code in app/dcsp/app/functions/email_functions.py
18
19
20
21
22
23
def __init__(self) -> None:
    """Init

    Nothing is done in the initialisation phase
    """
    return

valid_syntax(email)

Checks if the syntax of an email string is corrent

This function only checks if the syntax of an email is correct. It does not confirm if the email exists or that the end-server is able to process the email

Parameters:

Name Type Description Default
email str

the email address to be assesed.

required

Returns:

Name Type Description
bool bool

True if a valid email, otherwise False.

Source code in app/dcsp/app/functions/email_functions.py
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
def valid_syntax(self, email: str) -> bool:
    """Checks if the syntax of an email string is corrent

    This function only checks if the syntax of an email is correct. It does
    not confirm if the email exists or that the end-server is able to
    process the email

    Args:
        email (str): the email address to be assesed.

    Returns:
        bool: True if a valid email, otherwise False.
    """
    if re.fullmatch(self._valid_email_regex, email):
        return True

    else:
        return False