feedback/
feedback.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		.socials(&[
23			SocialItem::new(Service::Twitter, "MyCo"),
24			SocialItem::new(Service::GitHub, "MyCo"),
25		])
26		.build()?;
27
28	let content = Content::builder()
29        .theme(Theme::Simple)
30		.header(header)
31		.text("Hey Alex,")
32		.text("I'm Jamie, founder of **MyCo**.")
33        .text("Could you spare a moment to reply to this email with your thoughts on our service? Your feedback is invaluable and directly influences our improvements.")
34		.text("When you hit reply, your email will go directly to me, and I read each and every one.")
35		.text("Thanks for your support,")
36        .signature("Jamie Parker")
37		.text("Jamie Parker\n\nFounder @ [MyCo](https://example.com)")
38		.footer(footer)
39		.build()?;
40
41	let email = Email::builder()
42		.to(EmailAddress::new(&email_address))
43		.subject("Confirm your email")
44		.content(content)
45		.build()?;
46
47	let templateless = Templateless::new(&api_key);
48	let _ = templateless.send(email).await?;
49
50	Ok(())
51}