Skip to content

Email Resource

Note: This capability is now provided as an installable component. See the Components guide for how to install and use it.

Install: kdeps component install email

Usage: run: { component: { name: email, with: { to: "...", subject: "...", body: "...", smtpHost: "...", smtpUser: "...", smtpPass: "..." } } }

The Email component sends email via SMTP using Python smtplib.

Note: The component supports sending only. For IMAP read/search/modify operations, use a Python resource with the imaplib library directly.

Component Inputs

InputTypeRequiredDefaultDescription
tostringyesRecipient email address
subjectstringyesEmail subject line
bodystringyesEmail body (plain text)
smtpHoststringyesSMTP server hostname
smtpPortintegerno587SMTP server port
smtpUserstringyesSMTP authentication username
smtpPassstringyesSMTP authentication password

Using the Email Component

yaml
run:
  component:
    name: email
    with:
      to: "recipient@example.com"
      subject: "Hello from KDeps"
      body: "Your workflow completed successfully."
      smtpHost: "smtp.example.com"
      smtpPort: 587
      smtpUser: "user@example.com"
      smtpPass: "app-password"

Access the result via output('<callerActionId>').


Result Map

FieldTypeDescription
successbooltrue when the email was accepted by the server.

Provider Quick-Reference

ProviderHostPort
Gmail (STARTTLS)smtp.gmail.com587
SendGridsmtp.sendgrid.net587
Mailgunsmtp.mailgun.org587
Amazon SESemail-smtp.<region>.amazonaws.com587
Postmarksmtp.postmarkapp.com587

Gmail: Use an App Password rather than your account password.


Expression Support

All fields support KDeps expressions:

yaml
run:
  component:
    name: email
    with:
      to: "{{ get('recipient') }}"
      subject: "[Report] {{ get('candidate_name') }} - {{ get('score') }}%"
      body: "{{ get('email_body') }}"
      smtpHost: "{{ env('SMTP_HOST') }}"
      smtpPort: 587
      smtpUser: "{{ env('SMTP_USER') }}"
      smtpPass: "{{ env('SMTP_PASS') }}"

Full Example: CV Matcher Distribution Email

yaml
- apiVersion: kdeps.io/v1
  kind: Resource

  metadata:
    actionId: send-email
    name: Email Distribution

  validations:
    skip: "{{ get('compute-match.is_match') == false }}"

  run:
    component:
      name: email
      with:
        to: "{{ get('distribution_list') }}"
        subject: >-
          [CV Match] {{ get('extract-cv.name') }} -
          {{ get('extract-jd.title') }}
          ({{ get('compute-match.score_pct') }}%)
        body: |
          CV/JD Match Report

          Candidate: {{ get('extract-cv.name') }}
          Position: {{ get('extract-jd.title') }}
          Match Score: {{ get('compute-match.score_pct') }}%
        smtpHost: "{{ env('SMTP_HOST') }}"
        smtpPort: 587
        smtpUser: "{{ env('SMTP_USERNAME') }}"
        smtpPass: "{{ env('SMTP_PASSWORD') }}"

Released under the Apache 2.0 License.