auto_emailer.config package¶
Submodules¶
auto_emailer.config.credentials module¶
-
class
Credentials(sender_email=None, password=None, port=None, host=None)[source]¶ Bases:
objectBase class for Auto Emailer credentials.
Parameters: - sender_email (Optional[str]) – The user name to authenticate SMTP client. Can be None if environment variables are configured. Equivalent environment variable: EMAILER_SENDER.
- password (Optional[str]) – The password to authenticate SMTP client. Can be None if environment variables are configured. Equivalent environment variable: EMAILER_PASSWORD.
- port (Optional[str]) – The port number of SMTP server. Equivalent environment variable: EMAILER_HOST. If neither config nor environment variable are set, then it will default to 587.
- host (Optional[str]) – Host name of SMTP server. Equivalent environment variable: EMAILER_PORT. If neither config nor environment variable are set, then it will attempt to guess the host from the emailer_address.
Warning
Raises warning if port or host are none.
-
sender_email¶ User name for SMTP client.
-
password¶ Password for SMTP client.
-
port¶ Port where SMTP server is listening.
-
host¶ SMTP server host name.
-
static
fill_missing_user_info(info)[source]¶ Fills in automatically assigns EMAILER_PORT or EMAILER_HOST if they not set. Sets the default port to 587 and attempts to guess the host from the EMAILER_SENDER.
Parameters: info (dict) – Config dictionary object in auto_emailer format for initializing auto_emailer.config.credentials.Credentials()class instance.Returns: Dictionary object with missing information filled. Return type: dict Raises: ValueError– If it cannot guess EMAILER_HOST from EMAILER_SENDER.
Creates a Credentials instance from parsed authorized user info.
Parameters: info (dict) – Config dictionary object in auto_emailer format for initializing auto_emailer.config.credentials.Credentials()class instance.Returns: The constructed credentials created from user configuration object. Return type: auto_emailer.config.credentials.Credentials Raises: ValueError– If the authorized user info is not in the expected format (missing keys).
Creates a Credentials instance from an authorized user json file.
Parameters: file_name (str) – The string path to the authorized user json file Returns: The constructed credentials created from user file attributes. Return type: auto_emailer.config.credentials.Credentials Raises: ValueError– If the authorized user file is not in the expected format (json).
auto_emailer.config.default module¶
-
_get_explicit_environ_credential_file()[source]¶ Gets file path from auto_emailer.config.environment_vars.emailer_credentials environment variable. If file is found, it will load the json file variables and return class.
Creates and returns a
auto_emailer.config.credentials.Credentialsinstance from the environment variable json file attributes.Returns: The constructed credentials created from the environment variable’s auto_emailer.config.environment_vars.EMAILER_CREDS()file attributes or None.Return type: auto_emailer.config.credentials.Credentials
-
_get_explicit_environ_credentials()[source]¶ Checks for any environment variables defined in auto_emailer.config.environment_vars. If variables found, then they are loaded and returned.
Creates and returns a
auto_emailer.config.credentials.Credentialsinstance from the environment variables.Returns: The constructed credentials created from the environment variables defined in auto_emailer.config.environment_vars()Return type: auto_emailer.config.credentials.Credentials Raises: EnvironmentError– If environment variable credentials are defined and set to None. Specifically checks, EMAILER_SENDER and EMAILER_PASSWORD.
-
default_credentials()[source]¶ Gets the default credentials for the current environment. Default credentials provides an easy way to obtain credentials to call auto_emailer.Emailer.
This function acquires credentials from the environment in the following order:
- If the environment variable auto_emailer.config.environment_vars.EMAILER_CREDS is set to the path of a valid JSON file, then it is loaded and returned.
- If explicit environment variables are set EMAILER_, then the credentials are loaded and returned.
Returns: The constructed credentials. Return type: auto_emailer.config.credentials.Credentials Raises: EnvironmentError– If no credentials were found, or if the credentials found were invalid.
auto_emailer.config.environment_vars module¶
Environment variables used by auto_emailer.config
-
EMAILER_CREDS= 'EMAILER_CREDS'¶ Environment variable defining location of auto-emailer file path of credentials.
This used by
auto_emailer.config.default_credentials()to explicitly set a file path of credentials json file.
-
EMAILER_SENDER= 'EMAILER_SENDER'¶ Environment variable providing the value of auto-emailer’s config attribute EMAILER_SENDER.
-
EMAILER_PASSWORD= 'EMAILER_PASSWORD'¶ Environment variable providing the value of auto-emailer’s config attribute EMAILER_PASSWORD.
-
EMAILER_HOST= 'EMAILER_HOST'¶ Environment variable providing the value of auto-emailer’s config attribute EMAILER_HOST.
-
EMAILER_PORT= 'EMAILER_PORT'¶ Environment variable providing the value of auto-emailer’s config attribute EMAILER_PORT.
Module contents¶
AutoEmailer Config Library for Python.