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

fix: Fixed senders name in email while using resend email provider #4329

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"prepare": "husky install",
"publish": "lerna publish from-package",
"setup:project": "npx --yes [email protected] i && node scripts/setup-env-files.js && pnpm build",

"clean": "lerna clean --yes && npm run prebuild",
"commit": "cz",
"nx": "nx",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ export class ResendHandler extends BaseHandler {
constructor() {
super('resend', ChannelTypeEnum.EMAIL);
}
buildProvider(credentials: ICredentials, from?: string) {
const config: { apiKey: string; from: string } = {
buildProvider(credentials: ICredentials, from?: string, senderName?: string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

credentials: ICredentials already includes the senderName.
So we don't need to pass senderName as an extra param. Also in the current implementation. In the mail.factory.ts file, only 2 params are being passed for all the providers.

const config: { apiKey: string; from: string; senderName?: string } = {
from: from as string,
apiKey: credentials.apiKey as string,
senderName,
};

this.provider = new ResendEmailProvider(config);
Expand Down
5 changes: 4 additions & 1 deletion providers/resend/src/lib/resend.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class ResendEmailProvider implements IEmailProvider {
private config: {
apiKey: string;
from: string;
senderName?: string;
}
) {
this.resendClient = new Resend(this.config.apiKey);
Expand All @@ -26,7 +27,9 @@ export class ResendEmailProvider implements IEmailProvider {
options: IEmailOptions
): Promise<ISendMessageSuccessResponse> {
const response: any = await this.resendClient.sendEmail({
from: options.from || this.config.from,
from: this.config?.senderName
? `${this.config?.senderName} <${options.from || this.config.from}>`
: options.from || this.config.from,
to: options.to,
subject: options.subject,
text: options.text,
Expand Down
Loading