Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature suggestion: Send plain text by default when react email component is provided #451

Open
mbifulco opened this issue Dec 4, 2024 · 5 comments · May be fixed by #469
Open

Feature suggestion: Send plain text by default when react email component is provided #451

mbifulco opened this issue Dec 4, 2024 · 5 comments · May be fixed by #469

Comments

@mbifulco
Copy link

mbifulco commented Dec 4, 2024

I noticed a warning in Resend's insights feature that my nicely styled react emails weren't sending plaintext in addition to the formatted message:

image

I don't know what gave me this perception, but I assumed that resend would automatically generate a plaintext message when a react-email component was supplied to generate an email message.

My suggestion is that plaintext generation should be the default behavior.

For now, I've accomplished this on my personal site here -

  import { render } from '@react-email/render';
  import { Resend } from 'resend';

  import { WelcomeEmail } from './templates/WelcomeEmail';

  const resend = new Resend(env.RESEND_API_KEY);

  export const sendWelcomeEmail = async ({
    return;
  }
  
  // this component is made using react-email
  const WelcomeMessage = <WelcomeEmail firstName={firstName} />;

  // send the email
  const { data, error } = await resend.emails.send({
    from: 'Example <[email protected]>',
    to: [email],
    subject: "Welcome message subject line",
    react: WelcomeMessage,                                    // react component
    text: await render(WelcomeMessage, { plainText: true }),  // plaintext 
  });

The pattern I'm using for generating plaintext is derived from resend/react-email#320

@Rustix69
Copy link

Rustix69 commented Dec 5, 2024

I would like work on this issue, if that's okay.

@mbifulco
Copy link
Author

I would like work on this issue, if that's okay.

@Rustix69 go for it! I'd love to see this added to the library.

@joaoalberto-dev
Copy link

@Rustix69 are you working on this? I put together a fix on my end so if you need some help we can pair on this PR.

@joaoalberto-dev
Copy link

@bukinoshita do you think this change makes sense? I have a PR ready that I'm using on my end via patch.

@jvgomg
Copy link

jvgomg commented Feb 22, 2025

I believed the plaintext would automatically send too. I only found out it didn't when I went to have a look at an unrelated issue in the Resend dashboard and too a look at the "Insights" tab.

I think the fact you wire up the React component to a property called react, the fact that react-email dev tools show you the plaintext preview, and that there is no mention in the docs about how to send HTML and Plaintext emails together indicates that it would "just work".

If automatically including the plaintext when sending is not a good idea, for some reason, it would be good to indicate this in the docs or have a way to turn it on with a prop like includeText when calling .send().

Otherwise - keep up the good work, Resend peeps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants