Skip to main content

Email Sink

Introduction

The Email Sink is a Vanus Connector which aims to handle incoming CloudEvents in a way that extracts the data part of the original event and deliver these extracted data to SMTP server.

For example, the incoming CloudEvent looks like:

{
"id": "53d1c340-551a-11ed-96c7-8b504d95037c",
"source": "quick-start",
"specversion": "1.0",
"type": "quick-start",
"datacontenttype": "application/json",
"time": "2022-10-26T10:38:29.345Z",
"data": {
"to": "example@example.com",
"subject": "vanus auto mail",
"body": "this is vanus test email",
"body_type": "text"
}
}

then recipients will receive an email

Quick Start

in this section, we show how to use Email Sink sends a text message to recipients.

Create Config file

cat << EOF > config.yml
email:
account: "example@example.com"
password: "123456"
host: "smtp.gmail.com"
EOF
NameRequiredDefaultDescription
portNO8080the port which Email Sink listens on
email.accountYES-email account address you want to use
email.passwordYES-password for account authentication
email.hostYES-SMTP server address
email.portNO25SMTP server port

The Email Sink tries to find the config file at /vanus-connect/config/config.yml by default. You can specify the position of config file by setting the environment variable CONNECTOR_CONFIG for your connector.

Start with Docker

docker run -it --rm \
-p 31080:8080 \
-v ${PWD}:/vanus-connect/config \
--name sink-email public.ecr.aws/vanus/connector/sink-email

Test

curl --location --request POST 'localhost:18080' \
--header 'Content-Type: application/cloudevents+json' \
--data-raw '{
"id": "53d1c340-551a-11ed-96c7-8b504d95037c",
"source": "quick-start",
"specversion": "1.0",
"type": "quick-start",
"datacontenttype": "application/json",
"time": "2022-10-26T10:38:29.345Z",
"data": {
"to": "example@example.com",
"subject": "vanus auto mail",
"body": "this is vanus test email"
}
}'

now, you cloud see a new email in your mailbox.

Clean

docker stop sink-email

Sink details

Event Data Schema

AttributeRequiredDescription
subjectYESEmail subject
bodyYESEmail body
toYESEmail to
body_typeNOEmail body type, text or html, default text