refactor: update email configuration to use fromEmail and supportEmail in website settings

This commit is contained in:
javayhu 2025-04-25 00:30:04 +08:00
parent 222154397a
commit b0ebee8633
6 changed files with 13 additions and 11 deletions

View File

@ -34,7 +34,7 @@ export const sendMessageAction = actionClient
try {
const { name, email, message } = parsedInput;
if (!websiteConfig.mail.contact) {
if (!websiteConfig.mail.supportEmail) {
console.error('The mail receiver is not set');
throw new Error('The mail receiver is not set');
}
@ -43,7 +43,7 @@ export const sendMessageAction = actionClient
// Send message as an email to admin
const result = await sendEmail({
to: websiteConfig.mail.contact,
to: websiteConfig.mail.supportEmail,
template: 'contactMessage',
context: {
name,

View File

@ -62,13 +62,13 @@ export default async function AboutPage() {
{t('introduction')}
</p>
{websiteConfig.mail.contact && (
{websiteConfig.mail.supportEmail && (
<div className="flex items-center gap-4">
<Button className="rounded-lg cursor-pointer">
<MailIcon className="mr-1 size-4" />
<a href={`mailto:${websiteConfig.mail.contact}`}>
{t('talkWithMe')}
</a>
<a href={`mailto:${websiteConfig.mail.supportEmail}`}>
{t('talkWithMe')}
</a>
</Button>
</div>
)}

View File

@ -89,7 +89,7 @@ export default function HeroSection() {
speedSegment={0.3}
delay={0.5}
as="p"
className="mx-auto mt-8 max-w-2xl text-balance text-lg"
className="mx-auto mt-8 max-w-4xl text-balance text-lg text-muted-foreground"
>
{t('description')}
</TextEffect>

View File

@ -59,7 +59,8 @@ export const websiteConfig: WebsiteConfig = {
},
mail: {
provider: 'resend',
contact: 'support@mksaas.com',
fromEmail: 'support@mksaas.com',
supportEmail: 'support@mksaas.com',
},
newsletter: {
provider: 'resend',

View File

@ -26,7 +26,7 @@ export class ResendProvider implements MailProvider {
throw new Error('RESEND_API_KEY environment variable is not set.');
}
if (!websiteConfig.mail.contact) {
if (!websiteConfig.mail.fromEmail) {
throw new Error(
'Default from email address is not set in websiteConfig.'
);
@ -34,7 +34,7 @@ export class ResendProvider implements MailProvider {
const apiKey = process.env.RESEND_API_KEY;
this.resend = new Resend(apiKey);
this.from = websiteConfig.mail.contact;
this.from = websiteConfig.mail.fromEmail;
}
/**

View File

@ -99,7 +99,8 @@ export interface BlogConfig {
*/
export interface MailConfig {
provider: 'resend'; // The email provider, only resend is supported for now
contact?: string; // Sender email address, as well as recipient email address
fromEmail?: string; // The email address to send from
supportEmail?: string; // The email address to send support emails to
}
/**