auto_emailer package¶
Subpackages¶
Submodules¶
auto_emailer.emailer module¶
-
class
Emailer
(config=None, delay_login=True)[source]¶ Bases:
object
Welcome to the auto-emailer to send all of your emails!
Parameters: - config (Optional(config.credentials.Credentials)) – The constructed credentials. Can be None if environment variables are configured.
- delay_login (bool) – If True, no login attempt will be made until send_mail is called. Otherwise, a login attempt will be made at class initialization.
Raises: ValueError
– If config is not in the expected format.EnvironmentError
– If default_credentials is called and environment variables are not found.
-
send_email
(message, from_addr=None, to_addrs=None, delay_send=0)[source]¶ Send an email message through the SMTP client.
The message may either be a string containing characters in the ASCII range, or an auto_emailer.emailer.Message object.
If the message is a string, the smtplib delivery method will use smtplib.sendmail.
If the message is an auto_emailer.emailer.Message object, the smtplib delivery method will use smtplib.send_message. The message is then converted to a bytestring and passes it to smtplib.sendmail. The arguments are the same as for sendmail, except that message is an auto_emailer.emailer.Message object. If from_addr is None or to_addrs is None, these arguments are taken from the headers of the message as described in RFC 2822 (a ValueError is raised if there is more than one set of ‘Resent-‘ headers).
Parameters: - message (Union[auto_emailer.emailer.Message, str]) – The message may either be a string containing characters in the ASCII range, or an auto_emailer.emailer.Message object.
- from_addr (Optional[str]) – The address sending the mail.
- to_addrs (Optional(Sequence[str])) – A list of addresses to send the email to. A bare string will be treated as a list with 1 address.
- delay_send (Optional[int]) – If you would like to delay sending the email, pass in amount of time in seconds.
Raises: ValueError
– If sending a string email and from_addr or to_addr is None.ValueError
– If the message is not an auto_emailer.emailer.Message object or a string.
-
class
Message
(sender, destinations, subject=None, cc=None, bcc=None)[source]¶ Bases:
object
Class representing an email message.
Parameters: - sender (str) – Email address of the sender (from).
- destinations (Sequence[str]) – List of string email addresses to send the email message to.
- subject (Optional[str]) – Subject of your email message.
- cc (Optional(Sequence[str])) – List of string email addresses to CC the email message to.
- bcc (Optional(Sequence[str])) – List of string email addresses to BCC on the email message.
-
static
body_template
(template_path)[source]¶ Opens, reads, and returns the given template text file path as a string.
Parameters: template_path (str) – File path for the email template. Returns: Text of file. Return type: str Raises: FileNotFoundError
– If cannot find the file from given template_path.
-
draft_message
(text=None, template_path=None, template_args=None)[source]¶ Create, or draft, the self.message instance attribute with string text or text file templates. Return self from the instance to allow method chaining of auto_emailer.emailer.Message.attach.
Parameters: Returns: The instance of auto_emailer.emailer.Message.
Return type:
-
attach
(attach_files=None)[source]¶ Add a sequence of files as attachments to the email message.
Parameters: attach_files (Optional(Sequence[str])) – List of string file paths to attached to message. Returns: The instance of auto_emailer.emailer.Message. Return type: auto_emailer.emailer.Message
Module contents¶
AutoEmailer Library for Python.