1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "emails": [
12 {
13 "id": "EXAMPLE-SALE",
14 "subject": "RE: your order",
15 "body": "<p>Black Friday: 40% off everything. Shop now!</p>"
16 },
17 {
18 "id": "EXAMPLE-OPTOUT",
19 "subject": "New arrivals are here",
20 "body": "<p>Shop the new collection.</p><p>To unsubscribe, log in to your account. Please allow up to 30 days for removal.</p><p>Example Co, 123 Main Street, Springfield, IL 62701</p>",
21 "headers": {
22 "List-Unsubscribe": "<mailto:unsubscribe@example.com>"
23 }
24 },
25 {
26 "id": "EXAMPLE-NEWS",
27 "subject": "October tips from Example Co",
28 "fromName": "Example Co",
29 "fromEmail": "news@example.com",
30 "body": "<p>Five ways to save energy this winter.</p><p>You're receiving this because you signed up at example.com. <a href='https://example.com/u'>Unsubscribe</a> | Manage preferences</p><p>Example Co, 123 Main Street, Springfield, IL 62701</p>",
31 "headers": {
32 "List-Unsubscribe": "<https://example.com/u/one-click>",
33 "List-Unsubscribe-Post": "List-Unsubscribe=One-Click"
34 }
35 }
36 ]
37};
38
39
40const run = await client.actor("ultimatemc/email-can-spam-checker").call(input);
41
42
43console.log('Results from dataset');
44console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
45const { items } = await client.dataset(run.defaultDatasetId).listItems();
46items.forEach((item) => {
47 console.dir(item);
48});
49
50