Many email clients and users prefer plain text versions of emails for several reasons:
Accessibility - Screen readers often work better with plain text
User Preference - Some users disable HTML emails for security or simplicity
Spam Filtering - Emails with both HTML and plain text versions are less likely to be marked as spam
Fallback - When HTML rendering fails, the plain text version is displayed
Most email services (SendGrid, Postmark, AWS SES) allow you to send both HTML and plain text versions in a single email. The recipient’s client chooses which to display.
<script> import { Html, Head, Body, Container, Heading, Text, Button, Link } from 'better-svelte-email'; interface Props { name: string; resetUrl: string; } let { name, resetUrl }: Props = $props();</script><Html> <Head /> <Body class="bg-gray-100 font-sans"> <Container class="bg-white p-8 rounded-lg"> <Heading as="h1">Password Reset Request</Heading> <Text> Hi {name}, </Text> <Text> We received a request to reset your password. Click the button below to create a new password: </Text> <Button href={resetUrl} class="bg-blue-500 text-white"> Reset Password </Button> <Text> Or copy this link into your browser: </Text> <Text> <Link href={resetUrl}>{resetUrl}</Link> </Text> <Text> If you didn't request this, you can safely ignore this email. </Text> </Container> </Body></Html>
<!-- Good: Clear call-to-action --><a href="https://example.com/reset">Reset your password</a><!-- Bad: Vague link text --><a href="https://example.com/reset">Click here</a>
<!-- Bad: Important info in image only --><img src="promo-code.png" alt="Use code SAVE20" /><!-- Good: Important info in text --><p>Use code SAVE20 for 20% off</p><img src="promo-code.png" alt="Promo code visual" />
For complex emails, you might want to write custom plain text instead of relying on automatic conversion:
import Renderer from 'better-svelte-email/renderer';import WelcomeEmail from '$lib/emails/welcome.svelte';const renderer = new Renderer();const html = await renderer.render(WelcomeEmail, { props: { name: 'John' } });// Custom plain text versionconst text = `Hi John,Welcome to our service!Get started: https://example.com/get-startedNeed help? Reply to this email.Thanks,The Team`.trim();// Send both versionsawait sendEmail({ html, text});
When writing custom plain text, make sure it includes all the important information from the HTML version. Missing critical links or information can frustrate users.
Problem: Link text appears but URLs are missing.Cause: This shouldn’t happen with the default toPlainText() function.Solution: Verify you’re using the latest version of Better Svelte Email.
Problem: Plain text output is hard to read.Cause: Complex HTML structure doesn’t convert well.Solution: Simplify your HTML structure or write custom plain text.
Problem: You want alt text in the plain text version.Cause: Images are skipped by default.Solution: Currently, images are completely skipped. If you need alt text, consider writing custom plain text or opening a feature request.