@cakemail-org/cakemail-cli 1.7.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/.claude/settings.local.json +12 -0
  2. package/.env.example +40 -0
  3. package/.env.test.example +45 -0
  4. package/CHANGELOG.md +1031 -0
  5. package/README.md +41 -37
  6. package/audit-formats.js +128 -0
  7. package/cakemail.rb +20 -0
  8. package/dist/client.js +1 -1
  9. package/dist/client.js.map +1 -1
  10. package/dist/commands/account.js +1 -1
  11. package/dist/commands/account.js.map +1 -1
  12. package/dist/commands/attributes.js +1 -1
  13. package/dist/commands/attributes.js.map +1 -1
  14. package/dist/commands/campaigns.js +1 -1
  15. package/dist/commands/campaigns.js.map +1 -1
  16. package/dist/commands/contacts.js +1 -1
  17. package/dist/commands/contacts.js.map +1 -1
  18. package/dist/commands/emails.js +1 -1
  19. package/dist/commands/emails.js.map +1 -1
  20. package/dist/commands/interests.js +1 -1
  21. package/dist/commands/interests.js.map +1 -1
  22. package/dist/commands/lists.js +1 -1
  23. package/dist/commands/lists.js.map +1 -1
  24. package/dist/commands/logs.js +1 -1
  25. package/dist/commands/logs.js.map +1 -1
  26. package/dist/commands/reports.js +1 -1
  27. package/dist/commands/reports.js.map +1 -1
  28. package/dist/commands/segments.js +1 -1
  29. package/dist/commands/segments.js.map +1 -1
  30. package/dist/commands/senders.js +1 -1
  31. package/dist/commands/senders.js.map +1 -1
  32. package/dist/commands/suppressed.js +1 -1
  33. package/dist/commands/suppressed.js.map +1 -1
  34. package/dist/commands/tags.js +1 -1
  35. package/dist/commands/tags.js.map +1 -1
  36. package/dist/commands/templates.js +1 -1
  37. package/dist/commands/templates.js.map +1 -1
  38. package/dist/commands/transactional-templates.js +1 -1
  39. package/dist/commands/transactional-templates.js.map +1 -1
  40. package/dist/commands/webhooks.js +1 -1
  41. package/dist/commands/webhooks.js.map +1 -1
  42. package/dist/utils/config.js +2 -2
  43. package/dist/utils/config.js.map +1 -1
  44. package/dist/utils/errors.js +1 -1
  45. package/dist/utils/errors.js.map +1 -1
  46. package/dist/utils/progress.d.ts.map +1 -1
  47. package/dist/utils/progress.js +32 -4
  48. package/dist/utils/progress.js.map +1 -1
  49. package/dist/utils/spinner.d.ts +17 -0
  50. package/dist/utils/spinner.d.ts.map +1 -0
  51. package/dist/utils/spinner.js +43 -0
  52. package/dist/utils/spinner.js.map +1 -0
  53. package/docs/DOCUMENTATION-STANDARD.md +1068 -0
  54. package/docs/README.md +161 -0
  55. package/docs/developer/ARCHITECTURE.md +516 -0
  56. package/docs/developer/AUTH.md +204 -0
  57. package/docs/developer/CONTRIBUTING.md +227 -0
  58. package/docs/developer/DOCUMENTATION_SUMMARY.md +346 -0
  59. package/docs/developer/PROJECT_INDEX.md +365 -0
  60. package/docs/planning/API_COVERAGE.md +1045 -0
  61. package/docs/planning/BACKLOG.md +1159 -0
  62. package/docs/planning/PROFILE_SYSTEM_TASKS.md +287 -0
  63. package/docs/planning/UX_IMPLEMENTATION_PLAN.md +691 -0
  64. package/docs/planning/archive/RELEASE_CHECKLIST_v1.3.0.md +332 -0
  65. package/docs/planning/archive/RELEASE_v1.3.0.md +428 -0
  66. package/docs/planning/archive/cakemail-cli-ux-improvements.md +438 -0
  67. package/docs/planning/cakemail-profile-system-plan.md +1121 -0
  68. package/docs/testing/AI_USER_SIMULATION_DESIGN.md +1342 -0
  69. package/docs/testing/KENOGAMI_BIDIRECTIONAL_FLOW.md +1517 -0
  70. package/docs/testing/KENOGAMI_TRUTH_RECONCILIATION_SYSTEM.md +1369 -0
  71. package/docs/user-manual/.obsidian/app.json +1 -0
  72. package/docs/user-manual/.obsidian/appearance.json +1 -0
  73. package/docs/user-manual/.obsidian/core-plugins.json +33 -0
  74. package/docs/user-manual/.obsidian/workspace.json +167 -0
  75. package/docs/user-manual/01-getting-started/01-installation.md +214 -0
  76. package/docs/user-manual/01-getting-started/02-quick-start.md +432 -0
  77. package/docs/user-manual/01-getting-started/03-authentication.md +448 -0
  78. package/docs/user-manual/01-getting-started/04-configuration.md +430 -0
  79. package/docs/user-manual/01-getting-started/05-output-formats.md +447 -0
  80. package/docs/user-manual/02-core-concepts/01-accounts.md +514 -0
  81. package/docs/user-manual/02-core-concepts/02-profile-system.md +771 -0
  82. package/docs/user-manual/02-core-concepts/03-smart-defaults.md +485 -0
  83. package/docs/user-manual/02-core-concepts/04-authentication-methods.md +435 -0
  84. package/docs/user-manual/02-core-concepts/05-pagination-filtering.md +600 -0
  85. package/docs/user-manual/02-core-concepts/06-error-handling.md +718 -0
  86. package/docs/user-manual/02-core-concepts/07-api-coverage.md +483 -0
  87. package/docs/user-manual/03-email-operations/01-senders.md +490 -0
  88. package/docs/user-manual/03-email-operations/02-templates.md +444 -0
  89. package/docs/user-manual/03-email-operations/03-transactional-emails.md +706 -0
  90. package/docs/user-manual/03-email-operations/04-email-tracking.md +407 -0
  91. package/docs/user-manual/04-campaign-management/01-campaigns-basics.md +394 -0
  92. package/docs/user-manual/04-campaign-management/02-campaign-scheduling.md +630 -0
  93. package/docs/user-manual/04-campaign-management/03-campaign-testing.md +997 -0
  94. package/docs/user-manual/04-campaign-management/04-campaign-lifecycle.md +709 -0
  95. package/docs/user-manual/04-campaign-management/05-campaign-links.md +934 -0
  96. package/docs/user-manual/05-contact-management/01-lists.md +836 -0
  97. package/docs/user-manual/05-contact-management/02-contacts.md +1035 -0
  98. package/docs/user-manual/05-contact-management/03-custom-attributes.md +788 -0
  99. package/docs/user-manual/05-contact-management/04-segments.md +1028 -0
  100. package/docs/user-manual/05-contact-management/05-contact-import-export.md +1031 -0
  101. package/docs/user-manual/06-analytics-reporting/01-campaign-analytics.md +867 -0
  102. package/docs/user-manual/06-analytics-reporting/02-account-reports.md +227 -0
  103. package/docs/user-manual/07-integrations/01-webhooks-integration.md +259 -0
  104. package/docs/user-manual/07-integrations/02-automation.md +326 -0
  105. package/docs/user-manual/08-advanced-usage/01-scripting-patterns.md +672 -0
  106. package/docs/user-manual/08-advanced-usage/02-bulk-operations.md +932 -0
  107. package/docs/user-manual/08-advanced-usage/03-ci-cd-integration.md +892 -0
  108. package/docs/user-manual/08-advanced-usage/04-performance-optimization.md +766 -0
  109. package/docs/user-manual/09-command-reference/01-config.md +776 -0
  110. package/docs/user-manual/09-command-reference/02-account.md +652 -0
  111. package/docs/user-manual/09-command-reference/03-lists.md +958 -0
  112. package/docs/user-manual/09-command-reference/04-contacts.md +1408 -0
  113. package/docs/user-manual/09-command-reference/05-attributes.md +617 -0
  114. package/docs/user-manual/09-command-reference/06-segments.md +894 -0
  115. package/docs/user-manual/09-command-reference/07-senders.md +803 -0
  116. package/docs/user-manual/09-command-reference/08-templates.md +818 -0
  117. package/docs/user-manual/09-command-reference/09-campaigns.md +1250 -0
  118. package/docs/user-manual/09-command-reference/10-emails.md +807 -0
  119. package/docs/user-manual/09-command-reference/11-reports.md +1135 -0
  120. package/docs/user-manual/09-command-reference/12-webhooks.md +773 -0
  121. package/docs/user-manual/09-command-reference/13-suppressed.md +797 -0
  122. package/docs/user-manual/09-command-reference/14-interests.md +630 -0
  123. package/docs/user-manual/09-command-reference/15-tags.md +584 -0
  124. package/docs/user-manual/09-command-reference/16-logs.md +656 -0
  125. package/docs/user-manual/09-command-reference/17-transactional-templates.md +850 -0
  126. package/docs/user-manual/10-troubleshooting/01-common-errors.md +457 -0
  127. package/docs/user-manual/10-troubleshooting/02-authentication-issues.md +558 -0
  128. package/docs/user-manual/10-troubleshooting/03-connection-problems.md +634 -0
  129. package/docs/user-manual/10-troubleshooting/04-debugging.md +725 -0
  130. package/docs/user-manual/11-appendix/04-faq.md +484 -0
  131. package/docs/user-manual/11-appendix/05-glossary.md +250 -0
  132. package/docs/user-manual/README.md +0 -0
  133. package/package.json +13 -61
  134. package/src/cli.ts +125 -0
  135. package/src/client.ts +16 -0
  136. package/src/commands/account.ts +267 -0
  137. package/src/commands/accounts.ts +78 -0
  138. package/src/commands/actions.ts +249 -0
  139. package/src/commands/attributes.ts +139 -0
  140. package/src/commands/campaign-blueprints.ts +106 -0
  141. package/src/commands/campaigns.ts +469 -0
  142. package/src/commands/config.ts +77 -0
  143. package/src/commands/contacts.ts +612 -0
  144. package/src/commands/custom-attributes.ts +127 -0
  145. package/src/commands/dkims.ts +117 -0
  146. package/src/commands/domains.ts +82 -0
  147. package/src/commands/email-apis.ts +569 -0
  148. package/src/commands/emails.ts +197 -0
  149. package/src/commands/forms.ts +283 -0
  150. package/src/commands/interests.ts +155 -0
  151. package/src/commands/links.ts +38 -0
  152. package/src/commands/lists.ts +406 -0
  153. package/src/commands/logos.ts +71 -0
  154. package/src/commands/logs.ts +386 -0
  155. package/src/commands/reports.ts +306 -0
  156. package/src/commands/segments.ts +158 -0
  157. package/src/commands/senders.ts +204 -0
  158. package/src/commands/sub-accounts.ts +271 -0
  159. package/src/commands/suppressed-emails.ts +234 -0
  160. package/src/commands/suppressed.ts +198 -0
  161. package/src/commands/system-emails.ts +85 -0
  162. package/src/commands/tags.ts +146 -0
  163. package/src/commands/tasks.ts +116 -0
  164. package/src/commands/templates.ts +189 -0
  165. package/src/commands/tokens.ts +83 -0
  166. package/src/commands/transactional-emails.ts +374 -0
  167. package/src/commands/transactional-templates.ts +385 -0
  168. package/src/commands/users.ts +506 -0
  169. package/src/commands/webhooks.ts +172 -0
  170. package/src/commands/workflow-blueprints.ts +123 -0
  171. package/src/commands/workflows.ts +265 -0
  172. package/src/types/profile.ts +93 -0
  173. package/src/utils/auth.ts +272 -0
  174. package/src/utils/config-file.ts +96 -0
  175. package/src/utils/config.ts +134 -0
  176. package/src/utils/confirm.ts +32 -0
  177. package/src/utils/defaults.ts +99 -0
  178. package/src/utils/errors.ts +116 -0
  179. package/src/utils/interactive.ts +91 -0
  180. package/src/utils/list-defaults.ts +74 -0
  181. package/src/utils/output.ts +190 -0
  182. package/src/utils/progress.ts +320 -0
  183. package/src/utils/spinner.ts +22 -0
  184. package/tests/IMPLEMENTATION_STATUS.md +258 -0
  185. package/tests/PTY_SETUP.md +118 -0
  186. package/tests/PTY_TESTING_GUIDE.md +507 -0
  187. package/tests/README.md +244 -0
  188. package/tests/fixtures/api-responses/campaigns.json +34 -0
  189. package/tests/fixtures/test-config.json +13 -0
  190. package/tests/helpers/cli-runner.ts +128 -0
  191. package/tests/helpers/mock-server.ts +301 -0
  192. package/tests/helpers/pty-runner.ts +181 -0
  193. package/tests/integration/campaigns-real-api.test.ts +196 -0
  194. package/tests/integration/setup-integration.ts +50 -0
  195. package/tests/pty/campaigns.test.ts +241 -0
  196. package/tests/setup.ts +34 -0
  197. package/tsconfig.json +15 -0
  198. package/vitest.config.ts +28 -0
@@ -0,0 +1,807 @@
1
+ # Email Commands
2
+
3
+ Send and track transactional emails using the Cakemail Email API v2.
4
+
5
+ ## Overview
6
+
7
+ Email commands allow you to:
8
+ - Send transactional emails with HTML and text content
9
+ - Use templates with dynamic parameters
10
+ - Track email opens and clicks
11
+ - Attach files to emails
12
+ - Tag emails for categorization
13
+ - View email delivery logs and status
14
+ - Render emails for testing
15
+
16
+ The Email API v2 is designed for transactional emails (password resets, receipts, notifications) rather than bulk marketing campaigns. For campaigns, use [campaign commands](/en/cli/command-reference/campaigns/).
17
+
18
+ ## Commands
19
+
20
+ - [emails send](#emails-send) - Submit an email to be sent
21
+ - [emails get](#emails-get) - Retrieve email details
22
+ - [emails render](#emails-render) - Render email HTML
23
+ - [emails logs](#emails-logs) - View Email API logs
24
+ - [emails tags](#emails-tags) - List email tags
25
+
26
+ ---
27
+
28
+ ## emails send
29
+
30
+ Submit a transactional email to be sent via Email API v2.
31
+
32
+ ### Usage
33
+
34
+ ```bash
35
+ cakemail emails send [options]
36
+ ```
37
+
38
+ ### Options
39
+
40
+ **Required:**
41
+ - `-t, --to <email>` - Recipient email address
42
+ - `-s, --subject <subject>` - Email subject
43
+
44
+ **Sender:**
45
+ - `--from-email <email>` - Sender email address
46
+ - `--from-name <name>` - Sender name
47
+ - `--reply-to <email>` - Reply-to email address
48
+
49
+ **Content (choose one approach):**
50
+ - `--html <html>` - HTML content (inline)
51
+ - `--html-file <path>` - Path to HTML file
52
+ - `--text <text>` - Plain text content (inline)
53
+ - `--text-file <path>` - Path to text file
54
+ - `--template-id <id>` - Use transactional template
55
+ - `--params <json>` - Template parameters as JSON
56
+
57
+ **Additional:**
58
+ - `--tracking` - Enable open and click tracking
59
+ - `--tags <tags>` - Comma-separated tags for categorization
60
+ - `--headers <json>` - Custom headers as JSON object
61
+ - `--attachments <json>` - Attachments as JSON array
62
+
63
+ ### Examples
64
+
65
+ **Send simple HTML email:**
66
+
67
+ ```bash
68
+ $ cakemail emails send \
69
+ -t john@example.com \
70
+ -s "Welcome to Our Service" \
71
+ --html "<h1>Welcome!</h1><p>Thanks for signing up.</p>" \
72
+ --from-email noreply@example.com \
73
+ --from-name "Example Team"
74
+ ```
75
+
76
+ **Output:**
77
+ ```
78
+ ✓ Email submitted: email_abc123
79
+ {
80
+ "id": "email_abc123",
81
+ "to": "john@example.com",
82
+ "subject": "Welcome to Our Service",
83
+ "status": "queued",
84
+ "submitted_at": "2024-03-15T10:30:00Z"
85
+ }
86
+ ```
87
+
88
+ **Send email from HTML file:**
89
+
90
+ ```bash
91
+ $ cakemail emails send \
92
+ -t jane@example.com \
93
+ -s "Your Receipt" \
94
+ --html-file ./templates/receipt.html \
95
+ --from-email receipts@example.com
96
+ ```
97
+
98
+ **Output:**
99
+ ```
100
+ ✓ Email submitted: email_def456
101
+ {
102
+ "id": "email_def456",
103
+ "to": "jane@example.com",
104
+ "subject": "Your Receipt",
105
+ "status": "queued"
106
+ }
107
+ ```
108
+
109
+ **Send with tracking enabled:**
110
+
111
+ ```bash
112
+ $ cakemail emails send \
113
+ -t user@example.com \
114
+ -s "Product Update" \
115
+ --html-file ./updates/march.html \
116
+ --from-email updates@example.com \
117
+ --tracking
118
+ ```
119
+
120
+ **Send with tags for categorization:**
121
+
122
+ ```bash
123
+ $ cakemail emails send \
124
+ -t customer@example.com \
125
+ -s "Order Confirmation" \
126
+ --html-file ./order-confirmation.html \
127
+ --from-email orders@example.com \
128
+ --tags "order,confirmation,automated"
129
+ ```
130
+
131
+ **Output:**
132
+ ```
133
+ ✓ Email submitted: email_ghi789
134
+ {
135
+ "id": "email_ghi789",
136
+ "to": "customer@example.com",
137
+ "tags": ["order", "confirmation", "automated"]
138
+ }
139
+ ```
140
+
141
+ **Send using template with parameters:**
142
+
143
+ ```bash
144
+ $ cakemail emails send \
145
+ -t user@example.com \
146
+ -s "Password Reset" \
147
+ --template-id 789 \
148
+ --params '{"reset_link":"https://example.com/reset/abc123","username":"John"}' \
149
+ --from-email security@example.com
150
+ ```
151
+
152
+ **Output:**
153
+ ```
154
+ ✓ Email submitted: email_jkl012
155
+ {
156
+ "id": "email_jkl012",
157
+ "template_id": 789,
158
+ "status": "queued"
159
+ }
160
+ ```
161
+
162
+ **Send with reply-to and custom headers:**
163
+
164
+ ```bash
165
+ $ cakemail emails send \
166
+ -t support-request@example.com \
167
+ -s "Support Ticket #1234" \
168
+ --html "<p>A new support ticket has been created.</p>" \
169
+ --from-email noreply@example.com \
170
+ --reply-to customer@example.com \
171
+ --headers '{"X-Ticket-ID":"1234","X-Priority":"high"}'
172
+ ```
173
+
174
+ **Send multipart (HTML + text):**
175
+
176
+ ```bash
177
+ $ cakemail emails send \
178
+ -t user@example.com \
179
+ -s "Newsletter" \
180
+ --html-file ./newsletter.html \
181
+ --text-file ./newsletter.txt \
182
+ --from-email newsletter@example.com
183
+ ```
184
+
185
+ ### Notes
186
+
187
+ - Must provide either content (HTML/text) or template ID
188
+ - HTML and text can be combined for multipart emails
189
+ - Tracking requires HTML content (not available for plain text only)
190
+ - Tags help organize and filter emails in logs
191
+ - Template parameters must be valid JSON
192
+ - Attachments require base64-encoded content in JSON format
193
+ - Rate limits apply based on your account tier
194
+
195
+ ### Related Commands
196
+
197
+ - [emails get](#emails-get) - Check email status
198
+ - [emails logs](#emails-logs) - View delivery logs
199
+ - [transactional-templates list](/en/cli/command-reference/transactional-templates#transactional-templates-list) - List templates
200
+
201
+ ---
202
+
203
+ ## emails get
204
+
205
+ Retrieve details and status of a submitted email.
206
+
207
+ ### Usage
208
+
209
+ ```bash
210
+ cakemail emails get <email-id>
211
+ ```
212
+
213
+ ### Arguments
214
+
215
+ - `email-id` - Email ID returned from [emails send](#emails-send)
216
+
217
+ ### Examples
218
+
219
+ **Get email details:**
220
+
221
+ ```bash
222
+ $ cakemail emails get email_abc123
223
+ ```
224
+
225
+ **Output:**
226
+ ```
227
+ {
228
+ "id": "email_abc123",
229
+ "to": "john@example.com",
230
+ "from": {
231
+ "email": "noreply@example.com",
232
+ "name": "Example Team"
233
+ },
234
+ "subject": "Welcome to Our Service",
235
+ "status": "delivered",
236
+ "submitted_at": "2024-03-15T10:30:00Z",
237
+ "delivered_at": "2024-03-15T10:30:15Z",
238
+ "opens": 1,
239
+ "clicks": 2,
240
+ "tags": ["welcome", "onboarding"]
241
+ }
242
+ ```
243
+
244
+ **Check if email was delivered:**
245
+
246
+ ```bash
247
+ $ cakemail emails get email_abc123 -f json | jq '.status'
248
+ ```
249
+
250
+ **Output:**
251
+ ```
252
+ "delivered"
253
+ ```
254
+
255
+ **Check email tracking stats:**
256
+
257
+ ```bash
258
+ $ cakemail emails get email_abc123 -f json | jq '{opens, clicks, status}'
259
+ ```
260
+
261
+ **Output:**
262
+ ```json
263
+ {
264
+ "opens": 1,
265
+ "clicks": 2,
266
+ "status": "delivered"
267
+ }
268
+ ```
269
+
270
+ ### Status Values
271
+
272
+ - `queued` - Email accepted and queued for sending
273
+ - `sent` - Email sent to recipient's mail server
274
+ - `delivered` - Email successfully delivered
275
+ - `bounced` - Email bounced (hard or soft bounce)
276
+ - `complained` - Recipient marked as spam
277
+ - `failed` - Email failed to send
278
+
279
+ ### Notes
280
+
281
+ - Status updates in real-time as email is processed
282
+ - Tracking stats only available if tracking was enabled
283
+ - Bounced emails include bounce reason
284
+ - Use this to verify delivery before follow-up actions
285
+
286
+ ### Related Commands
287
+
288
+ - [emails send](#emails-send) - Send email
289
+ - [emails logs](#emails-logs) - View all email logs
290
+
291
+ ---
292
+
293
+ ## emails render
294
+
295
+ Render the HTML content of a submitted email for testing or preview.
296
+
297
+ ### Usage
298
+
299
+ ```bash
300
+ cakemail emails render <email-id> [options]
301
+ ```
302
+
303
+ ### Arguments
304
+
305
+ - `email-id` - Email ID to render
306
+
307
+ ### Options
308
+
309
+ - `--as-submitted` - Render original submitted content (before processing)
310
+ - `--tracking` - Enable tracking links in rendered HTML
311
+
312
+ ### Examples
313
+
314
+ **Render email HTML:**
315
+
316
+ ```bash
317
+ $ cakemail emails render email_abc123
318
+ ```
319
+
320
+ **Output:**
321
+ ```
322
+ {
323
+ "html": "<!DOCTYPE html>\n<html>\n<head>...</head>\n<body>\n<h1>Welcome!</h1>\n<p>Thanks for signing up.</p>\n</body>\n</html>"
324
+ }
325
+ ```
326
+
327
+ **Render with tracking enabled:**
328
+
329
+ ```bash
330
+ $ cakemail emails render email_abc123 --tracking
331
+ ```
332
+
333
+ **Output:**
334
+ ```
335
+ {
336
+ "html": "<!DOCTYPE html>\n<html>\n<body>\n<h1>Welcome!</h1>\n<p>Thanks for signing up.</p>\n<img src='https://track.cakemail.com/open/...' />\n</body>\n</html>"
337
+ }
338
+ ```
339
+
340
+ **Save rendered HTML to file:**
341
+
342
+ ```bash
343
+ $ cakemail emails render email_abc123 -f json | jq -r '.html' > rendered.html
344
+ ```
345
+
346
+ **Render as originally submitted:**
347
+
348
+ ```bash
349
+ $ cakemail emails render email_abc123 --as-submitted
350
+ ```
351
+
352
+ ### Notes
353
+
354
+ - Useful for debugging email appearance
355
+ - `--tracking` shows how tracking pixels/links are inserted
356
+ - `--as-submitted` bypasses any post-processing
357
+ - Rendered HTML includes full document structure
358
+ - Template variables are replaced with actual values
359
+
360
+ ### Related Commands
361
+
362
+ - [emails get](#emails-get) - Get email metadata
363
+ - [emails send](#emails-send) - Send test email
364
+
365
+ ---
366
+
367
+ ## emails logs
368
+
369
+ View Email API activity logs with filtering and pagination.
370
+
371
+ ### Usage
372
+
373
+ ```bash
374
+ cakemail emails logs [options]
375
+ ```
376
+
377
+ ### Options
378
+
379
+ - `--from <date>` - Start date (YYYY-MM-DD format)
380
+ - `--to <date>` - End date (YYYY-MM-DD format)
381
+ - `--tag <tag>` - Filter by tag
382
+ - `--status <status>` - Filter by status (delivered, bounced, etc.)
383
+ - `-l, --limit <number>` - Limit number of results
384
+ - `-p, --page <number>` - Page number
385
+
386
+ ### Examples
387
+
388
+ **View recent logs:**
389
+
390
+ ```bash
391
+ $ cakemail emails logs
392
+ ```
393
+
394
+ **Output:**
395
+ ```
396
+ ┌──────────────┬─────────────────────┬─────────────┬───────────┬─────────────────────┐
397
+ │ ID │ To │ Subject │ Status │ Submitted │
398
+ ├──────────────┼─────────────────────┼─────────────┼───────────┼─────────────────────┤
399
+ │ email_abc123 │ john@example.com │ Welcome... │ delivered │ 2024-03-15 10:30:00 │
400
+ │ email_def456 │ jane@example.com │ Receipt │ delivered │ 2024-03-15 09:15:00 │
401
+ │ email_ghi789 │ bob@example.com │ Update │ bounced │ 2024-03-15 08:00:00 │
402
+ └──────────────┴─────────────────────┴─────────────┴───────────┴─────────────────────┘
403
+ ```
404
+
405
+ **Filter by date range:**
406
+
407
+ ```bash
408
+ $ cakemail emails logs --from 2024-03-01 --to 2024-03-15
409
+ ```
410
+
411
+ **Filter by status:**
412
+
413
+ ```bash
414
+ $ cakemail emails logs --status bounced
415
+ ```
416
+
417
+ **Output:**
418
+ ```
419
+ ┌──────────────┬─────────────────────┬─────────────┬───────────┬─────────────────────┐
420
+ │ ID │ To │ Subject │ Status │ Submitted │
421
+ ├──────────────┼─────────────────────┼─────────────┼───────────┼─────────────────────┤
422
+ │ email_ghi789 │ bob@example.com │ Update │ bounced │ 2024-03-15 08:00:00 │
423
+ │ email_jkl012 │ invalid@bad.com │ Alert │ bounced │ 2024-03-14 16:20:00 │
424
+ └──────────────┴─────────────────────┴─────────────┴───────────┴─────────────────────┘
425
+ ```
426
+
427
+ **Filter by tag:**
428
+
429
+ ```bash
430
+ $ cakemail emails logs --tag "order" -l 10
431
+ ```
432
+
433
+ **Output:**
434
+ ```
435
+ ┌──────────────┬─────────────────────┬─────────────┬───────────┬─────────────┐
436
+ │ ID │ To │ Subject │ Status │ Tags │
437
+ ├──────────────┼─────────────────────┼─────────────┼───────────┼─────────────┤
438
+ │ email_mno345 │ customer@ex.com │ Order #1001 │ delivered │ order,conf │
439
+ │ email_pqr678 │ buyer@example.com │ Order #1002 │ delivered │ order,conf │
440
+ └──────────────┴─────────────────────┴─────────────┴───────────┴─────────────┘
441
+ ```
442
+
443
+ **Combine filters:**
444
+
445
+ ```bash
446
+ $ cakemail emails logs \
447
+ --from 2024-03-01 \
448
+ --to 2024-03-15 \
449
+ --status delivered \
450
+ --tag "welcome" \
451
+ -l 50
452
+ ```
453
+
454
+ **Export logs to JSON:**
455
+
456
+ ```bash
457
+ $ cakemail emails logs --from 2024-03-01 --to 2024-03-15 -f json > email-logs.json
458
+ ```
459
+
460
+ ### Status Filter Values
461
+
462
+ - `queued` - Email in queue
463
+ - `sent` - Email sent
464
+ - `delivered` - Successfully delivered
465
+ - `bounced` - Bounced (hard or soft)
466
+ - `complained` - Marked as spam
467
+ - `failed` - Failed to send
468
+
469
+ ### Notes
470
+
471
+ - Logs are retained for 90 days
472
+ - Date range is required for large result sets
473
+ - Use pagination for large log volumes
474
+ - Tags help organize and filter transactional emails
475
+ - Status filter helps identify delivery issues
476
+
477
+ ### Related Commands
478
+
479
+ - [emails get](#emails-get) - Get individual email details
480
+ - [emails tags](#emails-tags) - List all email tags
481
+ - [reports emails](/en/cli/command-reference/reports#reports-emails) - Email API analytics
482
+
483
+ ---
484
+
485
+ ## emails tags
486
+
487
+ List all tags used in Email API emails.
488
+
489
+ ### Usage
490
+
491
+ ```bash
492
+ cakemail emails tags
493
+ ```
494
+
495
+ ### Examples
496
+
497
+ **List all email tags:**
498
+
499
+ ```bash
500
+ $ cakemail emails tags
501
+ ```
502
+
503
+ **Output:**
504
+ ```
505
+ {
506
+ "tags": [
507
+ {
508
+ "name": "order",
509
+ "count": 1234
510
+ },
511
+ {
512
+ "name": "confirmation",
513
+ "count": 1180
514
+ },
515
+ {
516
+ "name": "welcome",
517
+ "count": 456
518
+ },
519
+ {
520
+ "name": "password-reset",
521
+ "count": 234
522
+ },
523
+ {
524
+ "name": "notification",
525
+ "count": 890
526
+ }
527
+ ]
528
+ }
529
+ ```
530
+
531
+ **Extract tag names:**
532
+
533
+ ```bash
534
+ $ cakemail emails tags -f json | jq -r '.tags[].name'
535
+ ```
536
+
537
+ **Output:**
538
+ ```
539
+ order
540
+ confirmation
541
+ welcome
542
+ password-reset
543
+ notification
544
+ ```
545
+
546
+ **Find most used tags:**
547
+
548
+ ```bash
549
+ $ cakemail emails tags -f json | jq '.tags | sort_by(.count) | reverse | .[0:5]'
550
+ ```
551
+
552
+ **Output:**
553
+ ```json
554
+ [
555
+ {"name": "order", "count": 1234},
556
+ {"name": "confirmation", "count": 1180},
557
+ {"name": "notification", "count": 890},
558
+ {"name": "welcome", "count": 456},
559
+ {"name": "password-reset", "count": 234}
560
+ ]
561
+ ```
562
+
563
+ ### Notes
564
+
565
+ - Tags are created automatically when used in [emails send](#emails-send)
566
+ - Count shows total emails with each tag
567
+ - Tags are case-sensitive
568
+ - Use tags to organize transactional email types
569
+ - Tags help filter logs and analytics
570
+
571
+ ### Related Commands
572
+
573
+ - [emails send](#emails-send) - Send email with tags
574
+ - [emails logs](#emails-logs) - Filter logs by tag
575
+
576
+ ---
577
+
578
+ ## Common Workflows
579
+
580
+ ### Workflow 1: Send Order Confirmation
581
+
582
+ ```bash
583
+ # Send confirmation email with tracking
584
+ $ cakemail emails send \
585
+ -t customer@example.com \
586
+ -s "Order #1234 Confirmed" \
587
+ --html-file ./templates/order-confirmation.html \
588
+ --from-email orders@example.com \
589
+ --from-name "Example Store" \
590
+ --tracking \
591
+ --tags "order,confirmation"
592
+
593
+ # Save email ID from output (e.g., email_abc123)
594
+
595
+ # Verify delivery
596
+ $ cakemail emails get email_abc123
597
+
598
+ # Check if opened
599
+ $ cakemail emails get email_abc123 -f json | jq '{status, opens, clicks}'
600
+ ```
601
+
602
+ ### Workflow 2: Send Password Reset
603
+
604
+ ```bash
605
+ # Generate reset token (your application logic)
606
+ RESET_TOKEN="abc123xyz"
607
+ RESET_LINK="https://example.com/reset/${RESET_TOKEN}"
608
+
609
+ # Send password reset email
610
+ $ cakemail emails send \
611
+ -t user@example.com \
612
+ -s "Password Reset Request" \
613
+ --template-id 789 \
614
+ --params "{\"reset_link\":\"${RESET_LINK}\",\"username\":\"John\"}" \
615
+ --from-email security@example.com \
616
+ --tags "password-reset,automated" \
617
+ --reply-to support@example.com
618
+
619
+ # Monitor delivery
620
+ $ cakemail emails logs --tag "password-reset" -l 1
621
+ ```
622
+
623
+ ### Workflow 3: Test Email Template
624
+
625
+ ```bash
626
+ # Send test email
627
+ $ cakemail emails send \
628
+ -t developer@example.com \
629
+ -s "Test: New Template" \
630
+ --html-file ./templates/new-design.html \
631
+ --from-email test@example.com \
632
+ --tracking
633
+
634
+ # Get email ID (e.g., email_test123)
635
+
636
+ # Render to verify HTML
637
+ $ cakemail emails render email_test123 -f json | jq -r '.html' > test-render.html
638
+
639
+ # Open in browser
640
+ $ open test-render.html
641
+
642
+ # Check tracking implementation
643
+ $ cakemail emails render email_test123 --tracking -f json | jq -r '.html' | grep -o 'track.cakemail.com'
644
+ ```
645
+
646
+ ### Workflow 4: Monitor Bounces
647
+
648
+ ```bash
649
+ # Check recent bounces
650
+ $ cakemail emails logs --status bounced --from 2024-03-01 -l 50
651
+
652
+ # Get details of bounced emails
653
+ $ cakemail emails get email_bounce123 -f json | jq '{to, status, bounce_reason}'
654
+
655
+ # Export bounced emails for cleanup
656
+ $ cakemail emails logs --status bounced --from 2024-03-01 -f json | \
657
+ jq -r '.data[] | .to' > bounced-emails.txt
658
+
659
+ # Add to suppression list (prevents future sends)
660
+ $ cat bounced-emails.txt | while read email; do
661
+ cakemail suppressed add -e "$email" -r "hard-bounce"
662
+ done
663
+ ```
664
+
665
+ ### Workflow 5: Daily Email Report
666
+
667
+ ```bash
668
+ # Create daily report script
669
+ #!/bin/bash
670
+ TODAY=$(date +%Y-%m-%d)
671
+ YESTERDAY=$(date -d "yesterday" +%Y-%m-%d)
672
+
673
+ # Export yesterday's email logs
674
+ cakemail emails logs --from $YESTERDAY --to $TODAY -f json > daily-report-$YESTERDAY.json
675
+
676
+ # Generate summary
677
+ echo "Email Summary for $YESTERDAY"
678
+ echo "Total emails: $(jq '.count' daily-report-$YESTERDAY.json)"
679
+ echo "Delivered: $(jq '[.data[] | select(.status=="delivered")] | length' daily-report-$YESTERDAY.json)"
680
+ echo "Bounced: $(jq '[.data[] | select(.status=="bounced")] | length' daily-report-$YESTERDAY.json)"
681
+ ```
682
+
683
+ ## Best Practices
684
+
685
+ 1. **Use Templates**: Create reusable templates for common transactional emails
686
+ 2. **Tag Everything**: Tag all emails for better organization and filtering
687
+ 3. **Enable Tracking**: Use tracking to measure engagement
688
+ 4. **Multipart Emails**: Include both HTML and text for better deliverability
689
+ 5. **Reply-To Address**: Set reply-to for customer responses
690
+ 6. **Monitor Bounces**: Regularly check bounce logs and clean lists
691
+ 7. **Test Before Production**: Use [emails render](#emails-render) to test templates
692
+ 8. **Rate Limiting**: Respect API rate limits for bulk sends
693
+ 9. **Error Handling**: Always check email status after sending
694
+ 10. **Suppression List**: Use suppression list to prevent sending to invalid addresses
695
+
696
+ ## Troubleshooting
697
+
698
+ ### Error: "Either HTML, text, or template-id is required"
699
+
700
+ Email content is missing.
701
+
702
+ **Solution:**
703
+ ```bash
704
+ # Provide HTML content
705
+ $ cakemail emails send -t user@example.com -s "Subject" --html "<p>Content</p>" --from-email sender@example.com
706
+
707
+ # Or use template
708
+ $ cakemail emails send -t user@example.com -s "Subject" --template-id 123 --from-email sender@example.com
709
+ ```
710
+
711
+ ### Email Status: "bounced"
712
+
713
+ Email bounced (invalid address or delivery failure).
714
+
715
+ **Solution:**
716
+ ```bash
717
+ # Check bounce reason
718
+ $ cakemail emails get email_abc123 -f json | jq '.bounce_reason'
719
+
720
+ # Add to suppression list
721
+ $ cakemail suppressed add -e "bounced@example.com" -r "hard-bounce"
722
+
723
+ # Verify email address is valid before sending
724
+ ```
725
+
726
+ ### Email Not Tracking
727
+
728
+ Tracking not enabled or HTML content missing.
729
+
730
+ **Solution:**
731
+ ```bash
732
+ # Enable tracking when sending
733
+ $ cakemail emails send -t user@example.com -s "Subject" --html-file content.html --tracking --from-email sender@example.com
734
+
735
+ # Verify tracking in rendered HTML
736
+ $ cakemail emails render email_abc123 --tracking | grep "track.cakemail.com"
737
+ ```
738
+
739
+ ### Template Parameters Not Working
740
+
741
+ Invalid JSON or missing parameters.
742
+
743
+ **Solution:**
744
+ ```bash
745
+ # Ensure valid JSON syntax
746
+ $ cakemail emails send \
747
+ -t user@example.com \
748
+ -s "Subject" \
749
+ --template-id 123 \
750
+ --params '{"name":"John","link":"https://example.com"}' \
751
+ --from-email sender@example.com
752
+
753
+ # Test template first
754
+ $ cakemail transactional-templates render 123 -p '{"name":"John"}'
755
+ ```
756
+
757
+ ### Rate Limit Exceeded
758
+
759
+ Sending too many emails too quickly.
760
+
761
+ **Solution:**
762
+ ```bash
763
+ # Add delays between sends in scripts
764
+ for email in $(cat recipients.txt); do
765
+ cakemail emails send -t "$email" -s "Subject" --html-file content.html --from-email sender@example.com
766
+ sleep 1 # 1 second delay
767
+ done
768
+
769
+ # Contact support for higher rate limits
770
+ ```
771
+
772
+ ### Email Marked as Spam
773
+
774
+ Poor sender reputation or content issues.
775
+
776
+ **Solution:**
777
+ ```bash
778
+ # Use verified sender address
779
+ $ cakemail senders list
780
+
781
+ # Avoid spam trigger words in subject
782
+ # Include unsubscribe link
783
+ # Authenticate domain (SPF, DKIM, DMARC)
784
+ # Check email deliverability score
785
+ ```
786
+
787
+ ### Missing Email Logs
788
+
789
+ Logs only retained for 90 days.
790
+
791
+ **Solution:**
792
+ ```bash
793
+ # Export logs regularly
794
+ $ cakemail emails logs --from 2024-03-01 --to 2024-03-15 -f json > archive-march.json
795
+
796
+ # Set up automated exports
797
+ # Create scheduled job to archive logs monthly
798
+ ```
799
+
800
+ ---
801
+
802
+ **Related Documentation:**
803
+ - [Transactional Templates Commands](/en/cli/command-reference/transactional-templates/) - Manage email templates
804
+ - [Senders Commands](/en/cli/command-reference/senders/) - Manage sender identities
805
+ - [Suppressed Commands](/en/cli/command-reference/suppressed/) - Manage suppression list
806
+ - [Reports Commands](/en/cli/command-reference/reports/) - Email API analytics
807
+ - [Campaigns Commands](/en/cli/command-reference/campaigns/) - Marketing campaigns