ConnectorTypeSMTP
class connector_types.connector_type_smtp.ConnectorTypeSMTP
Send an email using an SMTP server.
Input Schema
-
schema_version
Type:
string
-
authentication
Type:
anyOf
Options: -
host
The remote hostname or IP address.
Type:
string
-
port
Type:
anyOf
Options: -
tls
If to connect using TLS/SSL.
Type:
anyOf
Options: -
use_starttls
If set to
True
the SMTP server will be contacted using the STARTTLS command.Type:
boolean
-
mode
Type:
anyOf
Options: -
connect_timeout
A timeout for connecting to a peer in seconds.
Type:
integer
Default:
30
Output Schema
-
result
Data
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')