-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqr_code.py
95 lines (83 loc) · 2.39 KB
/
qr_code.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import os
import sys
from dotenv import load_dotenv
from templateless import (
Content,
Email,
EmailAddress,
Templateless,
Header,
SocialItem,
Service,
Footer,
Theme,
StoreBadgeItem,
StoreBadge,
)
def main():
load_dotenv()
api_key = os.getenv("TEMPLATELESS_API_KEY")
if api_key is None:
print("Set TEMPLATELESS_API_KEY to your Templateless API key")
sys.exit(1)
email_address = os.getenv("TEMPLATELESS_EMAIL_ADDRESS")
if email_address is None:
print("Set TEMPLATELESS_EMAIL_ADDRESS to your own email address")
sys.exit(1)
header = (
Header()
.image(src="https://templateless.net/myco.webp", width=100, alt="MyCo")
.build()
)
app_store_link = "https://apps.apple.com/us/app/example/id1234567890"
google_play_link = "https://play.google.com/store/apps/details?id=com.example"
footer = (
Footer()
.store_badges(
[
StoreBadgeItem(StoreBadge.APP_STORE, app_store_link),
StoreBadgeItem(StoreBadge.GOOGLE_PLAY, google_play_link),
]
)
.socials(
[
SocialItem(Service.TWITTER, "MyCo"),
SocialItem(Service.GITHUB, "MyCo"),
]
)
.build()
)
content = (
Content()
.theme(Theme.SIMPLE)
.header(header)
.text("Hey Alex,")
.text(
"Thank you for choosing MyCo! To get started with our mobile experience, simply pair your account with our mobile app."
)
.text("Here's how to do it:")
.text(
"\n".join(
[
f"1. Download the MyCo app from the [App Store]({app_store_link}) or [Google Play]({google_play_link}).",
"1. Open the app and select _Pair Device_.",
"1. Scan the QR code below with your mobile device:",
]
)
)
.qr_code("https://example.com/qr-code-link")
.text("Enjoy your seamless experience across devices!")
.footer(footer)
.build()
)
email = (
Email()
.to(EmailAddress(email_address))
.subject("How to Pair Device")
.content(content)
.build()
)
templateless = Templateless(api_key)
templateless.send(email)
if __name__ == "__main__":
main()