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 · 4 comments

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.

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

No branches or pull requests

3 participants