-
Notifications
You must be signed in to change notification settings - Fork 42
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
Have the text property automatically filled when the react property is used when sending emails. #369
Comments
Yes, having the text version of the email is usually recommended. We will explore more |
It seems this still hasn't been implemented. In the meantime, is this how you all would recommend working around this? import { Resend } from 'resend';
import { render } from '@react-email/render';
const resend = new Resend('re_123456789');
async function sendEmail() {
const jsx = <MyTemplate />;
const text = await render(jsx, {
plainText: true,
});
await resend.emails.send({
from: 'Acme <[email protected]',
to: ['[email protected]'],
subject: 'hello world',
react: jsx,
text,
});
} |
yeah this is how i am using it, but i must agree i would love it to have an option for async function sendEmail({
from,
to,
subject,
component,
}: {
from: string;
to: string | string[];
subject: string;
component: JSX.Element;
}) {
const [html, text] = await Promise.all([
render(component),
render(component, {
plainText: true,
},)
]);
const { data, error } = await resend.emails.send({
from,
to,
subject,
html: html,
text: text,
});
if (error) {
throw new Error(error.message);
}
return data;
} |
Do you recommend to always send a text version of an email along with the html version? If yes, could we have the SDK automatically set the
text
property when we use thereact
one (doing a second render with theplainText: true
option)?The text was updated successfully, but these errors were encountered: