mail page imap connection 3
This commit is contained in:
parent
ea4de624eb
commit
69f39607ea
@ -6,7 +6,7 @@ import { simpleParser } from 'mailparser';
|
|||||||
const imapConfig = {
|
const imapConfig = {
|
||||||
user: 'contact@governance-labs.org',
|
user: 'contact@governance-labs.org',
|
||||||
password: 'K!376c$6H#kMknM',
|
password: 'K!376c$6H#kMknM',
|
||||||
host: 'mail.infomniak.com',
|
host: 'mail.infomaniak.com',
|
||||||
port: 993,
|
port: 993,
|
||||||
tls: true,
|
tls: true,
|
||||||
tlsOptions: { rejectUnauthorized: false }
|
tlsOptions: { rejectUnauthorized: false }
|
||||||
@ -14,10 +14,11 @@ const imapConfig = {
|
|||||||
|
|
||||||
interface ImapMessage {
|
interface ImapMessage {
|
||||||
header: {
|
header: {
|
||||||
from: string[];
|
from?: string[];
|
||||||
to: string[];
|
to?: string[];
|
||||||
subject: string[];
|
subject?: string[];
|
||||||
date: string[];
|
date?: string[];
|
||||||
|
[key: string]: string[] | undefined;
|
||||||
};
|
};
|
||||||
body: string;
|
body: string;
|
||||||
attributes: {
|
attributes: {
|
||||||
@ -112,12 +113,12 @@ export async function GET(request: Request) {
|
|||||||
const processedMessages = messages.map((msg: ImapMessage, index: number) => ({
|
const processedMessages = messages.map((msg: ImapMessage, index: number) => ({
|
||||||
id: index + 1,
|
id: index + 1,
|
||||||
accountId: 1,
|
accountId: 1,
|
||||||
from: msg.header.from[0],
|
from: msg.header.from?.[0] || '',
|
||||||
fromName: msg.header.from[0].split('<')[0].trim(),
|
fromName: (msg.header.from?.[0] || '').split('<')[0].trim(),
|
||||||
to: msg.header.to[0],
|
to: msg.header.to?.[0] || '',
|
||||||
subject: msg.header.subject[0],
|
subject: msg.header.subject?.[0] || '',
|
||||||
body: msg.body,
|
body: msg.body || '',
|
||||||
date: msg.header.date[0],
|
date: msg.header.date?.[0] || new Date().toISOString(),
|
||||||
read: !(msg.attributes.flags.indexOf('\\Seen') < 0),
|
read: !(msg.attributes.flags.indexOf('\\Seen') < 0),
|
||||||
starred: !(msg.attributes.flags.indexOf('\\Flagged') < 0),
|
starred: !(msg.attributes.flags.indexOf('\\Flagged') < 0),
|
||||||
category: 'inbox'
|
category: 'inbox'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user