smtp

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

README

Endly inline workflow

endly -r=send

send.yaml

init:
defaults:
  target:
    URL: smtp://smtp.gmail.com:465
    credentials: smtp
  sender: viantemailtester@gmail.com

pipeline:
  send:
    action: smtp:send
    udf: Markdown
    mail:
      to:
      - awitas@viantinc.com
      from: $sender
      subject: Endly test
      contentType: text/html
      body:  "# test message\n
              * list item 1\n
              * list item 2"

Endly service action integration

Run the following command for exec service operation details:

endly -s=smtp -a=send

SMTP Service

Service Id Action Description Request Response
smtp send send an email to supplied recipients SendRequest SendResponse

RunRequest example

@run.json

{
  "Target": {
    "URL": "ssh://127.0.0.1/",
    "Credentials": "${env.HOME}/.secret/localhost.json"
  },
  "SuperUser":true,
  "Commands":["mkdir /tmp/app1"]
}

init:
defaults:
  target:
    URL: smtp://smtp.gmail.com:465
    credentials: smtp
  sender: viantemailtester@gmail.com

pipeline:
  send:
    action: smtp:send
    udf: Markdown
    mail:
      to:
      - awitas@viantinc.com
      from: $sender
      subject: Endly test
      contentType: text/html
      body:  "# test message\n
              * list item 1\n
              * list item 2"

Catching and seding errors

@run.yaml

init:
  - "body = Error: <strong>$error.Error at:</strong>
    $error.TaskName:
    <br />
    <code>
    $errorJSON
    </code>"
defaults:
  target:
    URL: smtp://smtp.gmail.com:465
    credentials: smtp
  sender: viantemailtester@gmail.com

pipeline:

  task1:
    action: fail
    message: test failure

  catch:
    action: smtp:send
    mail:
      to:
      - awitas@viantinc.com
      from: $sender
      subject: Endly test $error.Error
      contentType: text/html
      body: $body
  defer:
    action: print
    message: all done

Documentation

Index

Constants

View Source
const (
	//ServiceID represents smtp service id.
	ServiceID = "smtp"
)

Variables

This section is empty.

Functions

func New

func New() endly.Service

New creates a new NoOperation service.

func NewClient

func NewClient(target *url.Resource, credConfig *cred.Config) (*smtp.Client, error)

NewClient creates a new SMTP client.

Types

type MailMessage

type MailMessage struct {
	From        string `required:"true" description:"sender, has to match email from target.credentials"`
	To          []string
	Cc          []string
	Bcc         []string
	Subject     string
	Body        string
	ContentType string
}

MailMessage represent an email

func (*MailMessage) Payload

func (m *MailMessage) Payload() []byte

Payload returns mail payload.

func (*MailMessage) Receivers

func (m *MailMessage) Receivers() []string

Receivers returns all receivers for this email message

func (*MailMessage) Validate

func (m *MailMessage) Validate() error

Validate checks if mail message is valid

type SendRequest

type SendRequest struct {
	Target *url.Resource `required:"true" description:"SMTP endpoint"`
	Mail   *MailMessage  `required:"true"`
	UDF    string        `description:"body UDF"`
}

SendRequest represents send request.

func (*SendRequest) Validate

func (r *SendRequest) Validate() error

Validate validates send request.

type SendResponse

type SendResponse struct {
	SendPayloadSize int
}

SendResponse represents send response.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL