References

Newsletter Classes

class easynewsletter.Newsletter(email: easynewsletter.easyemail.Email, database: easynewsletter.database.Database)[source]

The subscriber class is for managing subscribers.

Parameters
  • email (Email) – It wants to get the Email class.

  • database (Database) – It wants to get the Database class.

Newsletter Functions

easynewsletter.Newsletter.add_subscriber(self, subscribers: List[easynewsletter.subscriber.Subscriber]) None

Adds the subscribers in the list to the database.

Parameters

subscribers (list) – List of Subscriber classes.

easynewsletter.Newsletter.remove_subscriber(self, subscribers: List[easynewsletter.subscriber.Subscriber]) None

Removes the subscribers in the list from the database.

Parameters

subscribers (list) – List of Subscriber classes.

easynewsletter.Newsletter.add_rule(self, message: easynewsletter.easyemail.Message, schedule: <module 'schedule' from '/home/docs/checkouts/readthedocs.org/user_builds/easynewsletter/envs/latest/lib/python3.7/site-packages/schedule/__init__.py'>) None

Add rules that should be called every time the job runs.

Parameters
  • message (Message) – It wants to get the Message class.

  • schedule (schedule) – It wants to get the Schedule class.

easynewsletter.Newsletter.run_pending(self, sleep_second: int = 1) None

Run all jobs that are scheduled to run.

Parameters

sleep_second (int) – Sleep time in seconds.

Subscriber Classes

class easynewsletter.Subscriber(email: str, active: bool = True)[source]

The subscriber class is for managing subscribers.

Parameters
  • email (str) – Email address of subscriber.

  • active (bool) – Activity status of subscriber.

Subscriber Functions

easynewsletter.Subscriber.user_name(self) str

Returns the name of the subscriber.

Returns

Name of the subscriber.

Return type

str

easynewsletter.Subscriber.domain(self) str

Returns the domain of the subscriber.

Returns

Name of the domain.

Return type

str

easynewsletter.Subscriber.to_tuple(self) tuple

Returns subscriber information as a tuple.

Returns

Subscriber informations.

Return type

tuple

Email Classes

class easynewsletter.Email(user_name: str, password: str, host: str, port: int)[source]

Email Class based on Red Mail.

Parameters
  • user_name (str) – User name to authenticate on the server.

  • password (str) – User password to authenticate on the server.

  • host (str) – SMTP host address.

  • port (int) – Port to the SMTP server.

Message Classes

class easynewsletter.Message(**kwargs)[source]

Class that stores message information.

Parameters
  • subject (str) – Subject of the email.

  • sender (str, optional) – Email address the email is sent from.

  • receivers (list, optional) – Receivers of the email.

  • cc (list, optional) – Cc or Carbon Copy of the email.

  • bcc (list, optional) – Blind Carbon Copy of the email.

  • html (str, optional) – HTML body of the email.

  • text (str, optional) – Text body of the email.

  • html_template (str, optional) – Name of the HTML template loaded using Jinja.

  • text_template (str, optional) – Name of the text template loaded using Jinja.

  • body_images (dict of bytes, dict of path-like, dict of plt Figure, dict of PIL Image, optional) – HTML images to embed with the html.

  • body_tables (dict of Pandas dataframes, optional) – HTML tables to embed with the html.

  • body_params (dict, optional) – Extra Jinja parameters passed to the HTML and text bodies.

  • attachments (dict, optional) – Attachments of the email. If dict value is string, the attachment content is the string itself.

Database Classes

class easynewsletter.Database(file_name: str = 'easynewsletter.db', table_name: str = 'Subscribers')[source]

Database class for subscribers.

Parameters
  • file_name (str) – Specifies the name of the database file.

  • table_name (str) – Specifies the name of the table to be created in the database.