Skip to content

The open alternative to Salesforce, designed for AI.

expose imap username field (#15866)

neo773cbb5bce500d4
diff --git a/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsConnectionForm.tsx b/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsConnectionForm.tsx
index 29879764b8f..841af508a90 100644
--- a/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsConnectionForm.tsx
+++ b/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsConnectionForm.tsx
@@ -120,6 +120,23 @@ export const SettingsAccountsConnectionForm = ({
)}
/>
+ <Controller
+ name="IMAP.username"
+ control={control}
+ render={({ field, fieldState }) => (
+ <SettingsTextInput
+ instanceId="imap-username-connection-form"
+ label={t`IMAP Username (Optional)`}
+ placeholder={t`john.doe`}
+ type="text"
+ value={field.value || ''}
+ required={false}
+ onChange={field.onChange}
+ error={fieldState.error?.message}
+ />
+ )}
+ />
+
<Controller
name="IMAP.password"
control={control}
diff --git a/packages/twenty-server/src/engine/core-modules/imap-smtp-caldav-connection/services/imap-smtp-caldav-connection.service.ts b/packages/twenty-server/src/engine/core-modules/imap-smtp-caldav-connection/services/imap-smtp-caldav-connection.service.ts
index f0e7b9c4681..05f11b46d0d 100644
--- a/packages/twenty-server/src/engine/core-modules/imap-smtp-caldav-connection/services/imap-smtp-caldav-connection.service.ts
+++ b/packages/twenty-server/src/engine/core-modules/imap-smtp-caldav-connection/services/imap-smtp-caldav-connection.service.ts
@@ -31,7 +31,7 @@ export class ImapSmtpCaldavService {
port: params.port,
secure: params.secure ?? true,
auth: {
- user: handle,
+ user: params.username ?? handle,
pass: params.password,
},
logger: false,
diff --git a/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/imap/providers/imap-client.provider.ts b/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/imap/providers/imap-client.provider.ts
index 826075fd034..3e391d9a147 100644
--- a/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/imap/providers/imap-client.provider.ts
+++ b/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/imap/providers/imap-client.provider.ts
@@ -1,5 +1,6 @@
import { Injectable, Logger } from '@nestjs/common';
+import { isNonEmptyString } from '@sniptt/guards';
import { ImapFlow } from 'imapflow';
import { ConnectedAccountProvider } from 'twenty-shared/types';
import { isDefined } from 'twenty-shared/utils';
@@ -88,7 +89,9 @@ export class ImapClientProvider {
port: connectionParameters.IMAP?.port || 993,
secure: connectionParameters.IMAP?.secure,
auth: {
- user: connectedAccount.handle,
+ user: isNonEmptyString(connectionParameters.IMAP?.username)
+ ? connectionParameters.IMAP?.username
+ : connectedAccount.handle,
pass: connectionParameters.IMAP?.password || '',
},
logger: false,