RestOC.SMTP module

SMTP

Wrapper for python smtp module

RestOC.SMTP.Send(to, subject, opts)

Sends an e-mail to one or many addresses based on a dictionary of options

Parameters
  • to (str|str[]) – The email or emails to send the email to

  • subject (str) – The subject of the email

  • opts (dict) –

    The options used to generate the email and any headers ‘html’: str ‘text’: str ‘from’: str, ‘reply-to’: str ‘cc’: str|str[] ‘bcc’: str|str[] ‘attachments’: list(str|dict(‘body’, ‘filename’))

    If an attachment is a string, a local filename is assumed, else if we receive a dictionary, it should contain the filename of the file, and the raw body of the file

Returns

bool

RestOC.SMTP.init(host='localhost', port=25, tls=False, user=None, passwd=None)

Called to change/set any SMTP information before sending out any e-mails

Parameters
  • host (str) – The hostname of the SMTP server

  • port (uint) – The port on the host

  • tls (bool) – Set to True if we need TLS

  • user (str) – The authorization username

  • passwd (str) – The authorization password

Returns

None

RestOC.SMTP.lastError()

Last Error

Returns the last error message if there is one

Returns

str

RestOC.SMTP.send(to, subject, text_body=None, html_body=None, from_='root@localhost', bcc=None, attachments=None)

Send

Sends an e-mail to one or many addresses

Parameters
  • to (str|str[]) – One or email addresses to send to

  • subject (str) – The email’s subject

  • text_body (str) – The text version of the main content of the email

  • html_body (str) – The html version of the main content of the email

  • from_ (str) – The from address of the email, optional

  • bcc (str|str[]) – Blind carbon copy addresses, optional

  • attachments

Returns

bool