Skip to main content
Version: 11 - TBD

ConnectorTypeSMTP

class connector_types.connector_type_smtp.ConnectorTypeSMTP

Send an email using an SMTP server.

Input Schema

  • schema_version

    Type: string

  • authentication

    Type: anyOf

  • host

    The remote hostname or IP address.

    Type: string

  • port

    Type: anyOf

  • tls

    If to connect using TLS/SSL.

    Type: anyOf

  • use_starttls

    If set to True the SMTP server will be contacted using the STARTTLS command.

    Type: boolean

  • mode

    Type: anyOf

  • connect_timeout

    A timeout for connecting to a peer in seconds.

    Type: integer

    Default: 30

Output Schema

Example

import flow_api

def handler(system: flow_api.System, this: flow_api.Execution, inputs: dict):
# create an SMTP connection and run it
this.connect(
connector_type='SMTP',
authentication={
'authentication_method': 'username_password',
'username': '...',
'password': '...',
},
host='...',
tls={
'tls_mode': 'no_tls_ssl',
},
use_starttls=True,
mode={
'mode_name': 'send_email',
'from_': 'Cloudomation <info@cloudomation.com>',
'to': 'info@cloudomation.com',
'subject': 'Cloudomation email',
# the text will be the email body. Alternatively you could add
# a html formatted body with the key 'html'.
'text': 'This email was sent with Cloudomation',
}
)
# the SMTP connection does not produce any outputs
return this.success(message='all done')

Sending attachments

import flow_api

def handler(system: flow_api.System, this: flow_api.Execution, inputs: dict):
this.connect(
connector_type='SMTP',
authentication={
'authentication_method': 'username_password',
'username': '...',
'password': '...',
},
host='...',
port={
'port_mode': 'port_number',
'port_number': 587,
},
tls={
'tls_mode': 'use_tls_ssl',
'server_ca': '...',
},
use_starttls=False,
mode={
'mode_name': 'send_email',
'from_': 'Cloudomation <info@cloudomation.com>',
'to': 'info@cloudomation.com',
'subject': 'Cloudomation email',
'html': '<h1>This email was sent with <a href="https://cloudomation.com"><strong>Cloudomation</strong></a></h1>',
'attachments': [
'file1.pdf',
'file2.zip',
],
},
)
# the SMTP connection does not produce any outputs
return this.success(message='all done')