fix: исправлена ошибка при отправке сообщения

This commit is contained in:
d.a.kolesov 2026-04-07 08:03:25 +07:00
parent a014ee5885
commit 59c21f1896
3 changed files with 24 additions and 14 deletions

View file

@ -37,8 +37,9 @@ function createComposeWindow(session: ComposeSession): void {
}
})
composeSessions.set(win.webContents.id, session)
win.on('closed', () => composeSessions.delete(win.webContents.id))
const webContentsId = win.webContents.id
composeSessions.set(webContentsId, session)
win.on('closed', () => composeSessions.delete(webContentsId))
if (process.env.ELECTRON_RENDERER_URL) {
win.loadURL(`${process.env.ELECTRON_RENDERER_URL}#/compose`)

View file

@ -267,9 +267,17 @@ export class ImapProvider implements IEmailProvider {
tls: { rejectUnauthorized: false } // самоподписанные сертификаты корпоративных серверов
})
// Если email хранится без домена (только логин) — достраиваем из IMAP-хоста
const emailAddress = this.config.email.includes('@')
? this.config.email
: `${this.config.email}@${creds.host.replace(/^[^.]+\./, '')}`
const from = this.config.label
? `"${this.config.label}" <${this.config.email}>`
: this.config.email
? { name: this.config.label, address: emailAddress }
: emailAddress
console.log('[SMTP] host=%s port=%d secure=%s user=%s from=%j to=%j',
smtpHost, smtpPort, smtpSecure, creds.username, from, compose.to)
const info = await transporter.sendMail({
from,
@ -315,7 +323,7 @@ export class ImapProvider implements IEmailProvider {
private async buildRawMessage(
messageId: string,
compose: ComposeData,
from: string
from: string | { name: string; address: string }
): Promise<Buffer | null> {
try {
const transporter = nodemailer.createTransport({ streamTransport: true, newline: 'unix' })

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, computed, onMounted, onUnmounted, nextTick } from 'vue'
import { ref, computed, onMounted, onUnmounted, nextTick, toRaw } from 'vue'
import type { ComposeSession, ComposeAttachment } from '@shared/types/message'
import { useIpc } from '../composables/useIpc'
import AppIcon from '../components/AppIcon.vue'
@ -177,19 +177,20 @@ async function handleSend(): Promise<void> {
sending.value = true
sendError.value = ''
try {
const sess = toRaw(session.value)
const result = await invoke('messages:send', {
accountId: session.value.accountId,
accountId: sess.accountId,
compose: {
to: to.value,
cc: cc.value,
bcc: bcc.value,
to: [...to.value],
cc: [...cc.value],
bcc: [...bcc.value],
subject: subject.value,
body: body.value,
attachments: attachments.value.map(({ path, filename, size }) => ({ path, filename, size })),
inReplyTo: session.value.inReplyTo,
references: session.value.references,
replyToMessageId: session.value.replyToMessageId,
replyToFolderId: session.value.replyToFolderId
inReplyTo: sess.inReplyTo,
references: sess.references ? [...sess.references] : undefined,
replyToMessageId: sess.replyToMessageId,
replyToFolderId: sess.replyToFolderId
}
})
if (result.success) {