Delivers MIL-006 tasks 1 to 4: the wiki pages in `docs/wiki/` in English, Danish and Bahasa Malaysia (Home plus one page per lecture step, each with its screenshot and a "what we gained" section, and a shared `_Sidebar.md`), laid out as `framework/process/wiki.md` says (English without suffix, `-da` and `-ms` for the others, a language line on every page). The README links to the wiki. Checked: the three languages have the same five pages; every page starts with the language line; code, commands and file names stay in English. There is no QC checklist for wiki pages, so there is no RC record. Publishing to the host's wiki (task 5, issue #31) follows after this merge. Task: MIL-006#1 Task: MIL-006#2 Task: MIL-006#3 Task: MIL-006#4
21 lines
1.5 KiB
Markdown
21 lines
1.5 KiB
Markdown
# Step 2: e-mail alert
|
|
|
|
🌐 **English** · [Dansk](Step-2-Email-Alert-da) · [Bahasa Melayu](Step-2-Email-Alert-ms)
|
|
|
|
**Assignment.** When the price is below a target (100), send an e-mail to yourself with the product title, the price and a link to buy it. Keep the e-mail address and password out of the code.
|
|
|
|
**What we built.** `check_price` compares the price with `TARGET_PRICE`. `SmtpNotifier` connects with `smtplib` on port 587, starts TLS, logs in and sends the message. `SMTP_ADDRESS`, `EMAIL_ADDRESS` and `EMAIL_PASSWORD` are read from `.env` with `python-dotenv`; `.env.example` shows the keys.
|
|
|
|
The screenshots come from a run where the SMTP connection is replaced by a stub, so no mail was sent; the second one is rendered from the message the code builds.
|
|
|
|

|
|
|
|

|
|
|
|
**What we gained**
|
|
|
|
- The SMTP conversation: connect, `starttls()`, `login()`, `sendmail()`; Gmail needs an App Password.
|
|
- Environment variables and `.env` files keep secrets out of the repository (`.env` is in `.gitignore`).
|
|
- A "below the target" rule that is a tiny pure function and easy to test (below, equal, above).
|
|
- Tests with a fake SMTP class: no real mail is ever sent by the tests.
|