Personalized images in emails
An image with the reader’s own name or numbers gets more attention than a generic banner: a welcome card, a renewal reminder, an invitation, a monthly summary. Email can’t run code, but it can show an image from a URL. This guide gives every recipient their own image URL, built in the code that sends the email.
How it works
- A template holds the design, with the personal values as props:
firstName,plan,daysLeft. - Your sending code signs one URL per recipient with their props. Signing happens on your server, with no API call per email.
- The email’s
<img>uses that URL. The image renders the first time it is loaded, usually when the email is opened, and is cached after that.
Step 1: build the template
Design it in the playground or have your AI assistant write it through the MCP server. Email images are smaller than web images:
export const props = {
firstName: "Priya",
plan: "Team",
daysLeft: "7",
};
type Props = typeof props;
export default function TrialReminder(props: Props) {
return (
<div class="flex h-full w-full flex-col justify-center gap-4 bg-indigo-600 p-12 text-white">
<span class="text-3xl text-indigo-200">Hi {props.firstName},</span>
<h1 class="m-0 text-6xl font-bold leading-tight">
{props.daysLeft} days left of your {props.plan} trial
</h1>
</div>
);
}
// 2x the size it is shown at (600 px wide), so it is sharp on retina screens.
export const options = { width: 1200, height: 500, format: "png" };
- Width. Most email layouts are 600 px wide. Render at 1200 px and show it at 600 px, so it stays sharp on high-density screens.
- Format. Use PNG or JPEG. Some email clients, including several Outlook versions, don’t show WebP.
- Text in the image is not text in the email. Screen readers and clients
that block images only see the
alttext, so put the message there too.
Step 2: sign a URL per recipient
In the playground, open the saved template, click the arrow next to Create
URL and choose Sign URLs in your code. It gives a ready-made function with
your template’s uid. Your signing key (jsxsk_…) is on the
API keys page; keep it on the server.
Save that function in your project, here as jsximage.js, and call it while
sending (Node.js):
import { imageUrl } from "./jsximage.js";
for (const user of trialUsers) {
const banner = await imageUrl({
firstName: user.firstName,
plan: user.planName,
daysLeft: String(user.trialDaysLeft),
});
await sendEmail({
to: user.email,
subject: `${user.trialDaysLeft} days left of your trial`,
html: `
<img src="${banner}" width="600" height="250"
alt="Hi ${user.firstName}, ${user.trialDaysLeft} days left of your ${user.planName} trial"
style="display:block;width:100%;max-width:600px;height:auto" />
…`,
});
}
That function puts text props in the query and sends anything else, like numbers
or lists, as JSON in one p parameter, so props keep their types. See
Props as JSON.
Good to know
- The URL is public. Anyone with the email can open the image. Use first names and plan names, never anything private like an address or a balance.
- Quota. Each URL uses one render the first time it is loaded. Many email clients load images through their own proxy, which then caches them, so opening an email again rarely loads it from JSXImage again, and it is free when it does.
- Same props, same URL. Two recipients with the same props share one URL and one render.
- Design changes show up in sent emails. The URL follows the template. If you change the design after sending, emails opened later show the new design. To freeze a campaign’s design, make a copy of the template for it.
- Test in real clients. Send a test to Gmail, Outlook and Apple Mail before a campaign.
Questions? See the docs or email info@jsximage.com.