Email

The platform6.email service allows the sending of emails.

Read the user guide of the Email service to discover its operating mode.

Sending an email

This resource will send an email using the JavaMail API.

Parameters

Headers of the request

Header’s key Description Value
platform6.request.action The action to perform (required) invoke
profile.name Email profile name to use for the request
profile.appkey Email profile appKey to use for the request
from Originator address
to Recipient address (required)
replyto Reply to address
cc Courtesy copy address
bcc Blind courtesy copy address
subject The email subject

Attachment of the request

Zero or more attachments can be specified. Unless using the fileurl header the attachment content must be specified as bytes.

Header’s key Description Value
name Used to identify the email body (required) body
type MIME Types (required)
filename Name for attachment
filenurl The URL of a file to attach

Headers of the response

Header’s key Description Value(s)
platform6.response.status Email send success OK, FAIL
platform6.response.value Email send message

Example

def cm = [
    headers: [
        'platform6.request.action': 'invoke',
        'from': 'myaccount@gmail.com',
        'to': 'simon.temple@amalto.com',
        'subject': 'Email Service Test'
    ],
    attachments: [
        [
            headers: [
                name: 'body',
                type: 'text/plain'
            ],
            bytes: 'This is email body content\n'.getBytes()
        ],
        [
            headers: [
                filename: 'hello.txt',
                type: 'text/plain'
            ],
            bytes: 'This is attachment content'.getBytes()
        ],
        [
            headers: [
                fileurl: 'file:///Volumes/Transcend/Downloads/logo.tiff'
            ]
        ]
    ]
]

def rcm = service.request('platform6.email', cm)

if( rcm.headers['platform6.response.status'] == 'OK') {
    // Send successful
}

The response will be:

platform6.response.status: OK, platform6.response.value: 1 email(s) sent successfully