Skip to content

Email for professionals and teams

improve receiving email from other domains in the same inbox

Hieu Nguyen (Jack)ac034e534439
diff --git a/src/app/api/mailboxes/[id]/route.ts b/src/app/api/mailboxes/[id]/route.ts
index 654d5a1..7d83ab6 100644
--- a/src/app/api/mailboxes/[id]/route.ts
+++ b/src/app/api/mailboxes/[id]/route.ts
@@ -55,22 +55,28 @@ export async function PATCH(request: Request, { params }: MailboxRouteParams) {
}
const updateValues = getMailboxUpdateValues(parsed.data);
+ if (parsed.data.useAllDomains === true) {
+ try {
+ await ensureMailboxDomainRouting(env, db, {
+ id: existing.id,
+ domainId: existing.domainId,
+ localPart: existing.localPart,
+ useAllDomains: true,
+ });
+ } catch (error) {
+ console.error("ensureMailboxDomainRouting", error);
+ return NextResponse.json(
+ { error: "Failed to configure inbound routing for all domains. Please try saving again." },
+ { status: 502 },
+ );
+ }
+ }
if (Object.keys(updateValues).length > 0) {
await db
.update(mailboxes)
.set(updateValues)
.where(eq(mailboxes.id, id));
}
- if (updateValues.useAllDomains && !existing.useAllDomains) {
- const [routingMailbox] = await db.select().from(mailboxes).where(eq(mailboxes.id, id)).limit(1);
- if (routingMailbox) {
- try {
- await ensureMailboxDomainRouting(env, db, routingMailbox);
- } catch (error) {
- console.warn("ensureMailboxDomainRouting", error);
- }
- }
- }
const [mailbox] = await selectMailboxForUser(db, user.id, id);
const { avatarKey, ...mailboxDetails } = mailbox!;
diff --git a/src/components/settings/account-settings.tsx b/src/components/settings/account-settings.tsx
index 9ff2a7a..8fff318 100644
--- a/src/components/settings/account-settings.tsx
+++ b/src/components/settings/account-settings.tsx
@@ -5,6 +5,7 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/com
import { Skeleton } from "@/components/ui/skeleton";
import { ChangePasswordForm } from "./change-password-form";
import { ProfileForm } from "./profile-form";
+import { ProfileAvatarForm } from "./profile-avatar-form";
import type { AccountSettingsResponse } from "./types";
import { loadAccountSettings } from "./utils";
@@ -54,6 +55,13 @@ export function AccountSettings() {
<CardDescription>Your current email is assigned to this account and cannot be changed here.</CardDescription>
</CardHeader>
<CardContent className="pb-6">
+ <div className="mb-6 flex items-center gap-4 border-b border-neutral-100 pb-6">
+ <ProfileAvatarForm name={user.name} />
+ <div>
+ <p className="text-sm font-medium text-neutral-900">Profile picture</p>
+ <p className="mt-1 text-sm text-neutral-500">Choose a picture to show across your account.</p>
+ </div>
+ </div>
<ProfileForm
initialName={user.name}
initialResetEmail={user.resetEmail ?? ""}