Skip to content

Commit

Permalink
Fix #18: add mail source kamelet
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaferraro committed Feb 26, 2021
1 parent 7115720 commit f4ab965
Show file tree
Hide file tree
Showing 4 changed files with 210 additions and 0 deletions.
68 changes: 68 additions & 0 deletions docs/modules/ROOT/assets/images/kamelets/mail-imap-source.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* xref:ROOT:bitcoin-source.adoc[image:kamelets/bitcoin-source.svg[] Bitcoin Source]
* xref:ROOT:http-source.adoc[image:kamelets/http-source.svg[] HTTP Source]
* xref:ROOT:jira-source.adoc[image:kamelets/jira-source.svg[] Jira Source]
* xref:ROOT:mail-imap-source.adoc[image:kamelets/mail-imap-source.svg[] Mail IMAP Source]
* xref:ROOT:minio-source.adoc[image:kamelets/minio-source.svg[] Minio Source]
* xref:ROOT:mqtt-source.adoc[image:kamelets/mqtt-source.svg[] MQTT Source]
* xref:ROOT:salesforce-source.adoc[image:kamelets/salesforce-source.svg[] Salesforce Source]
Expand Down
67 changes: 67 additions & 0 deletions docs/modules/ROOT/pages/mail-imap-source.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT
= image:kamelets/mail-imap-source.svg[] Mail IMAP Source

*Provided by: "Apache Software Foundation"*

Receive unread emails from an IMAP mail server, marking them as read once they are received.

== Configuration Options

The following table summarizes the configuration options available for the `mail-imap-source` Kamelet:
[width="100%",cols="2,^2,3,^2,^2,^3",options="header"]
|===
| Property| Name| Description| Type| Default| Example
| *host {empty}* *| Host| The IMAP server host| string| | `"imap.gmail.com"`
| *password {empty}* *| Password| The password to access the mail box| string| |
| *port {empty}* *| Port| The IMAP server port| string| `993`|
| *username {empty}* *| Username| The username to access the mail box| string| |
| delay| Delay| The delay between fetches in milliseconds| integer| `60000`|
| fetchSize| Fetch Size| The number of messages fetched for each poll (-1 for no limits)| integer| `10`|
|===

NOTE: Fields marked with ({empty}*) are mandatory.

== Usage

This section summarizes how the `mail-imap-source` can be used in various contexts.

=== Knative Source

The `mail-imap-source` Kamelet can be used as Knative source by binding it to a Knative object.

.mail-imap-source-binding.yaml
[source,yaml]
----
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
name: mail-imap-source-binding
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: mail-imap-source
properties:
host: "imap.gmail.com"
password: "The Password"
username: "The Username"
sink:
ref:
kind: InMemoryChannel
apiVersion: messaging.knative.dev/v1
name: mychannel
----

Make sure you have xref:latest@camel-k::installation/installation.adoc[Camel K installed] into the Kubernetes cluster you're connected to.

Save the `mail-imap-source-binding.yaml` file into your hard drive, then configure it according to your needs.

You can run the source using the following command:

[source,shell]
----
kubectl apply -f mail-imap-source-binding.yaml
----
// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT
74 changes: 74 additions & 0 deletions mail-imap-source.kamelet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
apiVersion: camel.apache.org/v1alpha1
kind: Kamelet
metadata:
name: mail-imap-source
annotations:
camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgI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DEgSCAxNC42ODU5MzggTCA4LjEsNy42ODU5Mzc1IFogTSAxLjEsMi4xIGwgNCw0IC00LDQgeiBtIDE0LDAgdiA4IGwgLTQsLTQgeiBNIDUuODA3MDMxMiw2LjgwNzAzMTIgOC4xLDkuMSAxMC4zOTI5NjksNi44MDcwMzEyIDE0LjY4NTkzOCwxMS4xIEggMS41MTQwNjI1IFoiCiAgICAgaWQ9InJlY3Q0MTQ0IgogICAgIGNsYXNzPSJDb2xvclNjaGVtZS1UZXh0IiAvPgo8L3N2Zz4K"
camel.apache.org/provider: "Apache Software Foundation"
labels:
camel.apache.org/kamelet.type: "source"
spec:
definition:
title: "Mail IMAP Source"
description: |-
Receive unread emails from an IMAP mail server, marking them as read once they are received.
required:
- host
- port
- username
- password
properties:
host:
title: Host
description: The IMAP server host
type: string
example: imap.gmail.com
port:
title: Port
description: The IMAP server port
type: string
default: 993
username:
title: Username
description: The username to access the mail box
type: string
password:
title: Password
description: The password to access the mail box
type: string
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:password
fetchSize:
title: Fetch Size
description: The number of messages fetched for each poll (-1 for no limits)
type: integer
default: 10
delay:
title: Delay
description: The delay between fetches in milliseconds
type: integer
default: 60000
flow:
from:
uri: "imaps:{{host}}:{{port}}"
parameters:
username: "{{username}}"
password: "{{password}}"
fetchSize: "{{fetchSize}}"
delay: "{{delay}}"
steps:
- set-header:
name: "ce-subject"
simple: "${header.Subject}"
- set-header:
name: "ce-from"
simple: "${header.From}"
- set-header:
name: "ce-to"
simple: "${header.To}"
- set-header:
name: "ce-cc"
simple: "${header.Cc}"
- convert-body-to:
type: "java.lang.String"
- to: "kamelet:sink"

0 comments on commit f4ab965

Please sign in to comment.