email:
    alert-gmail:
        type: gmail
        email: gramex.guide@gmail.com       # Generic email ID used to test e-mails
        password: tlpmupxnhucitpte          # App-specific password created for Gramex guide

url:
    alert/sendmail:
        pattern: /$YAMLURL/sendmail
        handler: FunctionHandler
        kwargs:
            function: alertapp.sendmail
    alert/alert:
        pattern: /$YAMLURL/alert
        handler: FileHandler
        kwargs:
            path: $YAMLPATH/alert.html
            template: true

alert:
  alert-email:
    to:
      - Admin <admin@example.org>
      - "Admin 2 <admin2@example.org>"
    cc: cc@example.org, cc2@example.org
    bcc: cc@example.org, cc2@example.org
    subject: Text email
    body: |
      This email is sent to multiple people. The to:, cc:, bcc: fields
      accept a list or a comma-separated string of email IDs.

  alert-html:
    to: admin@example.org
    subject: HTML email
    body: This content will only be displayed on devices that cannot render HTML email. That's rare.
    html: <p>This content will be shown in <em>HTML</em> on <strong>supported devices</strong>.

  alert-markdown:
    to: admin@example.org
    subject: Markdown email
    body: This content will only be displayed on devices that cannot render HTML email. That's rare.
    markdown: |
      This is Markdown content.
      Markup like *emphasis* and **strong** are supported.

  alert-content-file:
    to: admin@example.org
    subject: HTML email from file
    bodyfile: $YAMLPATH/email.txt       # Use email.txt in current directory
    htmlfile: $YAMLPATH/email.html      # Use email.html in current directory
    markdownfile: $YAMLPATH/email.md    # Use email.md in current directory

  alert-images:
    to: admin@example.org
    subject: Inline images
    markdown: |
      <p>This email has 2 inline images.</p>
      <p><img src="cid:img1"></p>
      <p><img src="cid:img2"></p>
    images:
      img1: $YAMLPATH/../uicomponents/bg-small.png
      img2: https://en.wikipedia.org/static/images/wikimedia-button.png

  alert-attachments:
    to: admin@example.org
    subject: Email with attachments
    html: This email contains attachments.
    attachments:
        - $YAMLPATH/doc1.docx
        - https://example.org/sample.pptx

  alert-notify:
    to: user@example.org
    subject: Email with notification
    html: This email will trigger a notification at the end.
    notify: [alert-notify-success]
  alert-notify-success:
    condition: not args['fail']
    to: admin@example.org
    subject: Email sent
    html: |
      {% import yaml %}
      <pre style="white-space:prewrap">{{ yaml.dump(args, default_flow_style=False) }}</pre>

  alert-templates:
    to: '{{ "admin@example.org" }}'
    subject: Template email
    html: |
      {% import sys %}
      <p>This email was sent from {{ sys.platform }}.</p>
      <p><img src="cid:img"></p>
      <p>{% raw open(r'$YAMLPATH/email.html').read() %}</p>
    images:
      img: '{% import os %}{{ os.path.join(r"$YAMLPATH", "../uicomponents/bg-small.png") }}'
    attachments:
      - '{% import os %}{{ os.path.join(r"$YAMLPATH", "doc1.docx") }}'

  alert-capture:
    to: admin@example.org
    subject: Dashboard attachment
    html:
      <h1>Sample dashboard</p>
      <p><img src="cid:img"></p>
    images:
      # TODO: avoid hard-coding the port
      img: 'http://localhost:9900/?url=http://localhost:9988/&ext=png'
    attachments:
      - 'http://localhost:9900/?url=http://localhost:9988/&ext=pdf'
    user:
      id: 'sample@example.org'
      role: 'custom-role'

encrypt:
  public_key: $HOME/.ssh/id_rsa.pub
  private_key: $HOME/.ssh/id_rsa
