Zum Hauptinhalt springen

Amazon SES Smart-Home-Integration, kostenlos und Open Source

Amazon SES-Integration fĂŒr Gladys Assistant

Unofficial: e-mails from your scenes sent through your Amazon SES account.

Info

Die Dokumentation dieser Integration wird von ihrem Autor geschrieben und ist bisher nur auf Englisch verfĂŒgbar.

Unofficial integration, not affiliated with Amazon Web Services. It sends e-mails from your scenes through your Amazon SES account with the SES API v2 (SendEmail, requests signed with AWS Signature Version 4); it never reads any. This integration has never been tested with a real AWS account: it was built from the official Amazon SES documentation and tested against local fake servers. Reports are welcome.

What leaves, and when​

An e-mail leaves only on one of these two paths:

  1. The “Send an e-mail with Amazon SES” scene action: one plain-text e-mail, with an optional subject (the default subject otherwise), to the recipients of the configuration: all of them when the “Recipient” field is empty, or the one it names. An address that is not in the list is refused and nothing leaves: a scene cannot write to anyone else. One recipient is put in “To”; several are put in blind copy (“Bcc”) only, so nobody sees the others' addresses. Its output message_id is the SES MessageId.
  2. The Test button: one e-mail from your sender to the SES mailbox simulator (success@simulator.amazonses.com), which SES accepts and drops. It checks the key, its permission and the sender. It works in the SES sandbox, but AWS bills it like any e-mail, so it is counted in the daily limit. In the sandbox, your recipients must be verified too: the Test does not check them, the first real e-mail does. If your IAM policy limits the recipients (ses:Recipients), allow the simulator address or the Test is denied.

Nothing is sent at start-up, on a schedule, on a reconnection or when the configuration is saved. The Gladys messages (“Send a message” action, system messages) are not relayed: this integration only serves scenes.

Setting up​

  1. In the Amazon SES console, in the region you will use, verify the sender address (or its domain): Configuration → Identities → Create identity. While your account is in the SES sandbox, verify every recipient address too (or request production access).

  2. In IAM, create a user for Gladys with only this permission (an inline policy):

    {
    "Version": "2012-10-17",
    "Statement": [{ "Effect": "Allow", "Action": "ses:SendEmail", "Resource": "*" }]
    }

    You may narrow Resource to your identity's ARN. Then Security credentials → Create access key: copy the access key ID (AKIA
) and the secret access key (shown once). Temporary keys (ASIA
) are refused: they need a session token.

  3. In Gladys, choose the region, fill in the access key ID, the secret access key, the sender address, optionally the sender name, the recipients (1 to 10 addresses separated by commas), the default subject and the daily limit; save, then click Test.

The secret access key is kept by Gladys in its database, never shown again, and sent only to Amazon SES, as a signature of each request: the key itself never travels.

What protects your account and your bill​

  • Fixed recipients and sender: only the administrator chooses them, in the configuration.
  • Daily limit (20 by default, 1 to 500): at most this many e-mails over any 24 hours, one per recipient (an e-mail to 3 recipients counts 3, as SES bills it; the Test e-mail counts 1). Beyond it nothing is sent (an e-mail that does not fit for all its recipients is refused whole) and the action fails with the time of the next possible e-mail. The count is kept in /data across restarts. An e-mail is counted before it leaves. It is given back only when nothing left: SES answered one of the refusals its documentation lists (below), or the connection never opened (connection refused, unknown name, network unreachable). No answer, a cut connection, a throttling (429, ThrottlingException), a 5xx, a redirect, a 4xx without an AWS error type (a proxy page) or with a type SES does not document there keep it counted: it may have left.
  • /data not safe: while /data is not read yet, unreadable, too slow (more than 1 second) or a write fails, the count could not survive a restart. Then only 2 e-mails per rolling 24 hours leave (counted in memory, one per recipient); the next is refused (“/data is unread, unreadable or cannot be written
”) and the status says so. A /data that does not exist yet (first start) is normal: the daily limit applies.
  • Never sent twice: SES accepts an e-mail with a 200 and its MessageId; the integration never sends an e-mail again, whatever happened. When SES did not confirm, the action fails with “it may have been sent, so it is not sent again”.
  • Texts bounded: subject on one line (line breaks removed), 200 characters at most; text 10,000 characters at most; plain text only, UTF-8.
  • One request at a time, 10 waiting; beyond, or when the wait would leave too little time, “too many e-mails at once” and nothing is sent. Two requests start at least 1 second per recipient of the first apart (the default SES sending rate is 1 e-mail per second). An e-mail waiting while the key, the region or the sender changes, or whose recipient is removed from the list, is not sent.
  • Pauses: after a throttling, a SES server error (5xx), a denial (AccessDeniedException, NotAuthorized, OptInRequired...), a paused or suspended account (SendingPausedException, AccountSuspendedException), a reached quota (LimitExceededException) or a clock SES finds off, nothing is sent for 60 seconds, doubled at each new failure up to 1 hour (a Retry-After is followed up to 6 hours), Test included. The pause is kept in /data. Saving another key, region or sender lifts a pause set by a denial, a paused account or the quota at once (a throttling, 5xx or clock pause stays).
  • Refused key: only UnrecognizedClientException, InvalidClientTokenId, InvalidSignatureException or SignatureDoesNotMatch (HTTP 403) with an AWS error type. Then nothing more is sent with this key until the key ID, the secret or the region changes or the Test button succeeds (the Test button tries a refused key too, outside a pause). Only two 8-bit prints of a salted HMAC are kept in /data, never the key; a new key entered while the integration runs is tried even if its prints happen to match (a key entered while it was stopped is blocked by such a match, 1 chance in 65,536: the Test button then lifts it). A signature refused because of the time (“Signature expired”, RequestExpired) is not a refusal of the key: the next requests are dated with the clock of SES (read from its answers) after the pause.
  • Address not verified (MessageRejected, MailFromDomainNotVerifiedException): nothing was sent and nothing is billed; the action fails and the status says to verify the sender or, in the sandbox, the recipients. No pause.

Status​

StatusMeaning
ReadySettings filled in; the key is checked at the first e-mail or the Test button.
Amazon SES accepted the last e-mailWith the count of the last 24 hours and the limit.
Amazon SES accepted the key, the sender and a test e-mailThe last Test succeeded (the simulator delivers nothing).
Refused key / denied / not verified / paused / limit reachedNothing is sent; the text says until when or what to change.
Daily counter not saved/data is unread, read-only or slow: only 2 e-mails per 24 hours leave until it works.

Privacy​

The logs show addresses masked (j***@e***.com); the key ID, the secret, subjects and texts are never logged, put in the status or written to /data, nor the texts of SES error answers (they may quote an address). /data/amazon-ses.json holds the times of the e-mails of the last 24 hours, the pause and the prints of a refused key.

Limits​

  • Plain text only; no attachment, no template, no HTML, no configuration set.
  • E-mails are not received; bounces and complaints are not read.
  • The SES quotas of your account (24-hour quota, sending rate) apply on top of the daily limit; every e-mail is billed by AWS.
  • Long-term IAM user keys only (no temporary credentials, no instance role).

Konfigurationseinstellungen​

Diese Einstellungen fragt Amazon SES in seinem Konfigurationsbildschirm in Gladys ab.

EinstellungTypPflichtfeldBeschreibung
Amazon SES in GladyssectionNeinUnofficial integration, not affiliated with Amazon Web Services. It only sends e-mails, never reads any, through the “Send an e-mail with Amazon SES” scene action, and only to the recipients listed below. In AWS, verify the sender address (or its domain) in Amazon SES, in the region chosen below; while the account is in the SES sandbox, verify every recipient too. Create an IAM user whose only permission is “ses:SendEmail”, give it an access key, then click “Test”: one e-mail goes to the SES mailbox simulator, which delivers nothing. Every e-mail is billed by AWS (the test one too); the daily limit below stops a runaway scene.
AWS regionselectNeinThe region where the sender is verified in Amazon SES (identities and sandbox are per region).
Access key IDstringJaOf an IAM user allowed “ses:SendEmail” only; starts with “AKIA”.
Secret access keysecretJaKept by Gladys in its database, never shown again, sent only to Amazon SES, and only as a signature of each request (the key itself never travels).
Sender addressstringJaMust be verified in Amazon SES in this region (the address or its domain), otherwise SES refuses every e-mail.
Sender namestringNein
RecipientsstringJa1 to 10 addresses separated by commas. The scenes write only to these: to all of them, or to the one the action names. With several, they receive one e-mail in blind copy (no one sees the others); each counts as one e-mail. In the SES sandbox, each must be verified.
Default subjectstringNeinUsed by the scene action when it gives no subject.
Daily limit of e-mailsnumberNeinAt most this many e-mails in any 24 hours, one per recipient, the Test e-mail included; beyond, nothing is sent and the action fails. Kept across restarts.

So installierst du Amazon SES in Gladys​

  1. Öffne in Gladys Integrationen: Amazon SES erscheint im Katalog neben den nativen Integrationen, mit einem Community-Badge.
  2. Klicke auf Installieren. Gladys lÀdt das Docker-Image (ghcr.io/lm1lc3n7/gladys-amazon-ses:0.1.1) herunter, startet es in einer vom Kern isolierten Sandbox und erzeugt die OberflÀche der Integration (GerÀte, Erkennung und Konfiguration).
  3. Öffne den Bildschirm Konfiguration der Integration, fĂŒlle die Einstellungen aus und speichere.
  4. Du kannst sie auch direkt ĂŒber die URL ihres Repositorys installieren: https://github.com/LM1LC3N7/gladys-amazon-ses.

Amazon SES benötigt Gladys >=5.1.0. Der Katalog in Gladys wird stĂŒndlich aktualisiert, eine neue Version ist also spĂ€testens eine Stunde nach ihrer Veröffentlichung verfĂŒgbar.

Du nutzt Gladys noch nicht? Es ist kostenlos und Open Source: folge der Installationsanleitung, um loszulegen.

Über externe Integrationen​

Amazon SES ist eine externe Integration: eine Community-Integration, die als Docker-Container verpackt und auf GitHub veröffentlicht wird. Gladys installiert sie mit einem Klick und fĂŒhrt sie in einer vom Kern isolierten Sandbox aus. Sie wird von LM1LC3N7 veröffentlicht und gepflegt, nicht vom Gladys-Kernteam.

Abonniere den Newsletter von Gladys Assistant

Ein paar E-Mails im Monat zu neuen Releases und Neuigkeiten aus dem Projekt. Verschickt von Pierre-Gilles Leymarie, dem GrĂŒnder des Projekts. Jederzeit abbestellbar 🙂