Emails
Email mechanics are a pillar for creating engagement with your users.
Loops
Setup
Create an account on Loops.
On your Dashboard go to
Settings
>API
and Generate KeyPaste it to your
.env
file
LOOPS_API_KEY=
Create a Transactional ID in
Transactional
> New, this will be the mail your users receive when they SignIn.Customize your email and Publish it, paste the
Publish
>transactionalId
value into your.env
file:

LOOPS_TRANSACTION_ID=
Set your DNS Records on
Settings
>Domain
> View records from your registrar (Cloudflare, NameCheap, Gandi...)
Contacts
DirectoryFast automatically add all the signed up users to your contact list.
If you want to update or modify this behavior, go to the /api/mailing/signin/route.ts file:
export async function POST(request: Request) {
const body = await request.json();
const res = await fetch(`https://app.loops.so/api/v1/contacts/create`, {
method: "POST",
body: JSON.stringify({
email: body.email,
subscribed: false,
}),
headers: {
Authorization: `Bearer ${process.env.LOOPS_API_KEY}`,
"Content-Type": "application/json",
},
});
return new Response(JSON.stringify(res), {
status: 201,
statusText: "Created",
headers: { "content-type": "application/json" },
});
}
Newsletter
The newsletter feature let visitors subscribe to your newsletter with or without signing up.
It adds those visitors to the contact list with the "subscribed" value set to "true".
To modify this, go to the /api/mailing/subscribe/route.ts file:
export async function POST(request: Request) {
const body = await request.json();
const res = await fetch(`https://app.loops.so/api/v1/contacts/create`, {
method: "POST",
body: JSON.stringify({
email: body.email,
source: "newsletter",
}),
headers: {
Authorization: `Bearer ${process.env.LOOPS_API_KEY}`,
"Content-Type": "application/json",
},
});
return new Response(JSON.stringify(res), {
status: 201,
statusText: "Created",
headers: { "content-type": "application/json" },
});
}
Last updated