email

Summit email library.

Functions

Name Summary
default_sender

Get the default sender

send

Create and send an email with the passed arguments.

Functions : email

default_sender(app_id)

Get the default sender This will find the default sender for an application. The default sender is the sender used if one is not given in the email.send command.

Parameters
Name Type Default Summary

app_id

string or nil

Optional application id. nil implies current application. Application id must be a string naming a UUID or the string "global" Global will only find email addresses which are usable for all applications within your domain.

Returns
Type Summary

string or nil

The default sender email address, if one exists.

Usage
local email = require "summit.email"
my_default_sender = email.default_sender()

send(to_addr, from_addr, subject, body, options)

Create and send an email with the passed arguments. Note that from_addr has to be approved for your domain. If from_addr is left as nil, some approved address will be used, if there is one.

Parameters
Name Type Default Summary

to_addr

string or table

‘To’ address. This can either be a single address, or a list of addresses.

from_addr

string

‘From’ address. May be nil.

subject

string

Email subject line

body

string

Email body content

options

table

Parameter: options
Name Type Default Summary

files

table

{}

Filename/Filehandle pairs to be sent with the email as attachments.

Returns
Type Summary

boolean

true if sending was successful, false otherwise

string or nil

Error message if unsuccessful, nil otherwise

Usage
local email = require('summit.email')
local asset = require('summit.asset')
local attachment = asset('attachment.txt')
email.send("receiver@example.com", "sender@example.com", "RE: Meeting", "We are meeting at 3:00 PM.", {files={['attachment.txt']=attachment}})
-- You could also use {"person1@example.com", "person2@example.com"} as the to_addr parameter.

-- Example for sending voice recording data
recording = channel.record()
email.send(
  "receiver@example.com",
  "sender@example.com",
  "New Voicemail",
  "You received a new voicemail from "..tostring(channel.data.remotenumber),
  {files={["message.wav"]=recording.wav}}
)