The SMTP connector is used to send email messages through a configured SMTP server.    

With this document guide you will be able to work with and use a SMTP Connector.

Features

  • Based on Standardized SMTP Protocol
  • Secure/Non-encrypted SMTP Server
  • Email message to multiple recipients
  • Multiple attachments possible along with the email-body
  • Attachments can be of the type .doc, .html, .odt, .xls and many more
  • An attachment of maximum 10 Mb size possible
  • Email body's can be of the types text/html, text/plain, multipart/alternative etc
  • Carbon Copy and Blind Carbon Copy options available
  • The ability to set Connector execution timeouts
  • Synchronous/Asynchronous execution of the Connector

Connector Configuration

add_smtp_connector

Configuration parameters- config(JSON)

ParameterDescriptionRequired
targetHost name or IP address of the SMTP servertrue
usernameUsername is the full email address of the sender's email accountfalse: config/request
passwordPassword associated with the sender's email accounttrue: config/request
portPort number on which the SMTP server is listening. Default port is25false: config/request
attachment_sizeSize of the file to be attached to an email message. A file of maximum 10 Mb size can be attachedfalse

 

Example

{
  "target": "smtp.gmail.com",
  "username": "example@gmail.com",
  "password": "example123",
  "post": 25,
  "attachment_size": 0.5
 } 



 

Actions

send

Send an email

Request parameters

ParameterDescriptionrequired
actionSpecify action as “send” for sending an email messagetrue
toUsername is the full email address of the sender's email accounttrue
fromUsernames of email accounts for whom the email message is meanttrue
subjectSpecify subject of an email message heretrue
bodyEmail message content mainly a texttrue
usernameUsername is the full email address of the sender's email account. Not required, if already specified in configuration filefalse
passwordPassword associated with the sender's email account. Not required, if already specified in configuration file.false
portPort number on which the SMTP server is listening. Default port is 25false
ccUsernames of email accounts who need to be kept informed of the email message content, but no actions required from them. Multiple usernames must be given within an array of stringsfalse
bccUsernames of email accounts you don't wish the other recipients to see that you sent it to this contact. Multiple usernames must be given within an array of stringsfalse
attachmentsFiles to be attached to an email message. Maximum size of a file that can be attached is 10 Mb. Multiple file names must be given within an array of stringsfalse
content-typeContent-type of the email body. Example : text/plain, multipart/alternative etc. Default content-type is text/htmlfalse

Response parameters

ParameterDescriptionrequired
resultMessage stating the status of mail deliverytrue

Example

response=@call.connector("my-smtp-connector")
              .set("action", "send" )
              .set("from", "email_test@gmail.com")
              .set("username", "email_test@gmail.com")
              .set("password", "example123")
              .set("to", [ "suzan_bones@gmail.com" , "kelly_90@gmail.com" ])
              .set("subject", "Testing Flint's SMTP Connector")
              .set("body","Hi, this is a test mail")
              .set("cc", [ "richard_133@gmail.com" , "caroline_9090@gmail.com" ])
              .set("bcc", [ "henry_clark@gmail.com" , "allen_jones@gmail.com"])
              .set("attachments", [ "Sample.txt" , "Example.doc" ])
              .set("content-type", "text/plain")
              .set("port" : 465)
              .sync

#SMTP Connector Response Parameters
result=response.get("result")                    #Result 
 

Connector request error handling

This is how success or failures can be handled for the connector requests within your Flintbit. This would help to take appropriate action if something failed.
if response.exitcode == 0               # 0 is success.
  puts "success"
  # take action in case of success
else                                    # non zero means fail
  puts "fail"
  puts "Reason:" + response.message     # get the reason of failure
  ## Take action in case of failure
end

 

 


On this page: