Can't use email pack in workflow


(ivan) #1

I tried use pack email in workflow but get the follow message:

result:
errors:

  • message: invalid syntax (, line 1)
    task_id: send_mail

This is task for send mail in workflow:

send_mail:
action: email.send_email account=“bot” email_from="bot@gmail.com" email_to="ivank@gmail.com" message=“message” subject=“Workflow”
next:
- when: <% succeeded() %>
- do: finish

Or this way:

send_mail:
action: email.send_email
input:
account: “bot”
email_from: "bot@gmail.com"
email_to: "ivank@gmail.com"
message: “message”
subject: “Workflow”
next:
- when: <% succeeded() %>
- do: finish

I can use action “email.send_email” from web and works fine


(W Chan) #2

In short, email_to needs to be array. When you run this email.send_mail action directly from the command line (or from web UI), we have extra logic there to put that string into an array. But working with the workflow, you will have to be more accurate. The following is an example that works.

    action: email.send_email
    input:
      account: "foobar"
      email_from: "foobar@gmail.com"
      email_to:
        - "fubar@gmail.com"
      message: "Relax! This is just a test."
      subject: "testing..." 

In the future, you can check the parameter type of the action by passing -h to st2 run <pack_name>.<action_name> -h. Here’s the output for email.send_email.

$ st2 run email.send_email -h

Send an email.

Required Parameters:
    account
        Account to use. Must be configured in email.yaml
        Type: string

    email_from
        Email address to use as FROM.
        Type: string

    email_to
        Email addresses to send TO.
        Type: array

    message
        Message to send on the email
        Type: string

    subject
        Subject of the email
        Type: string