verification/
verification.rs

1use templateless::{
2	components::{Image, Service, SocialItem},
3	utils, Content, Email, EmailAddress, Footer, Header, Result, Templateless,
4	Theme,
5};
6
7#[tokio::main]
8async fn main() -> Result<()> {
9	let api_key = utils::get_env("TEMPLATELESS_API_KEY");
10	let email_address = utils::get_env("TEMPLATELESS_EMAIL_ADDRESS");
11
12	let header = Header::builder()
13		.component(
14			Image::new("https://templateless.net/myco.webp")
15				.width(100)
16				.alt("MyCo")
17				.build()?,
18		)
19		.build()?;
20
21	let footer = Footer::builder()
22	.text("If you did not sign up for a MyCo account, please ignore this email.\nThis link will expire in 24 hours.")
23		.socials(&[
24			SocialItem::new(Service::Twitter, "MyCo"),
25			SocialItem::new(Service::GitHub, "MyCo"),
26		])
27		.link("Unsubscribe", "https://example.com")
28		.build()?;
29
30	let verify_email_link = "https://example.com/verify?token=ABC";
31
32	let content = Content::builder()
33        .theme(Theme::Simple)
34		.header(header)
35		.text("Hi there,")
36		.text("Welcome to **MyCo**! We're excited to have you on board. Before we get started, we need to verify your email address.")
37        .text("Please confirm your email by clicking the button below:")
38		.button("Verify Email", verify_email_link)
39		.text("Or use the link below:")
40		.link(verify_email_link, verify_email_link)
41		.footer(footer)
42		.build()?;
43
44	let email = Email::builder()
45		.to(EmailAddress::new(&email_address))
46		.subject("Confirm your email")
47		.content(content)
48		.build()?;
49
50	let templateless = Templateless::new(&api_key);
51	let _ = templateless.send(email).await?;
52
53	Ok(())
54}