Email

The Email enables you to send emails via Python, including attachments, and with HTML styling.

Usage

You can use this module in a few ways

  1. Import the whole py4pa package:

    import py4pa
    
    email = py4pa.Email(
       sender = 'test@gmail.com',
       server_add = 'relay.local',
       server_port = 25
    )
    
    log.info('Info message')
    
  2. Import the module directly:

    from py4pa import Email
    
    email = Email(
       sender = 'test@gmail.com',
       server_add = 'relay.local',
       server_port = 25
    )
    
    log.info('Info message')
    

Documentation

class py4pa.Email(sender, server_addr, server_port)

Bases: object

Helper class to manage creating email body & headers

This class does not currently include any authenticaion onto the email server

Parameters:
  • sender (str) – The email address you wish to appear in the ‘From’ field on the email. Can be just plain email: ‘example@gmail.com’, or alternatively in the format: ‘Example <example@gmail.com>’

  • server_addr (str) – The url of the email server you are connecting to, e.g. relay.abc.local

  • server_port (int) – The port through which the connection to the email server is made

send_email(recips, subject, cc=None, variables={}, attachments=None)
set_msg_templates(html_template, plain_template)