fix: исправлена ошибка при отправке сообщения
This commit is contained in:
parent
a014ee5885
commit
59c21f1896
3 changed files with 24 additions and 14 deletions
|
|
@ -37,8 +37,9 @@ function createComposeWindow(session: ComposeSession): void {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
composeSessions.set(win.webContents.id, session)
|
const webContentsId = win.webContents.id
|
||||||
win.on('closed', () => composeSessions.delete(win.webContents.id))
|
composeSessions.set(webContentsId, session)
|
||||||
|
win.on('closed', () => composeSessions.delete(webContentsId))
|
||||||
|
|
||||||
if (process.env.ELECTRON_RENDERER_URL) {
|
if (process.env.ELECTRON_RENDERER_URL) {
|
||||||
win.loadURL(`${process.env.ELECTRON_RENDERER_URL}#/compose`)
|
win.loadURL(`${process.env.ELECTRON_RENDERER_URL}#/compose`)
|
||||||
|
|
|
||||||
|
|
@ -267,9 +267,17 @@ export class ImapProvider implements IEmailProvider {
|
||||||
tls: { rejectUnauthorized: false } // самоподписанные сертификаты корпоративных серверов
|
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
|
const from = this.config.label
|
||||||
? `"${this.config.label}" <${this.config.email}>`
|
? { name: this.config.label, address: emailAddress }
|
||||||
: this.config.email
|
: 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({
|
const info = await transporter.sendMail({
|
||||||
from,
|
from,
|
||||||
|
|
@ -315,7 +323,7 @@ export class ImapProvider implements IEmailProvider {
|
||||||
private async buildRawMessage(
|
private async buildRawMessage(
|
||||||
messageId: string,
|
messageId: string,
|
||||||
compose: ComposeData,
|
compose: ComposeData,
|
||||||
from: string
|
from: string | { name: string; address: string }
|
||||||
): Promise<Buffer | null> {
|
): Promise<Buffer | null> {
|
||||||
try {
|
try {
|
||||||
const transporter = nodemailer.createTransport({ streamTransport: true, newline: 'unix' })
|
const transporter = nodemailer.createTransport({ streamTransport: true, newline: 'unix' })
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<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 type { ComposeSession, ComposeAttachment } from '@shared/types/message'
|
||||||
import { useIpc } from '../composables/useIpc'
|
import { useIpc } from '../composables/useIpc'
|
||||||
import AppIcon from '../components/AppIcon.vue'
|
import AppIcon from '../components/AppIcon.vue'
|
||||||
|
|
@ -177,19 +177,20 @@ async function handleSend(): Promise<void> {
|
||||||
sending.value = true
|
sending.value = true
|
||||||
sendError.value = ''
|
sendError.value = ''
|
||||||
try {
|
try {
|
||||||
|
const sess = toRaw(session.value)
|
||||||
const result = await invoke('messages:send', {
|
const result = await invoke('messages:send', {
|
||||||
accountId: session.value.accountId,
|
accountId: sess.accountId,
|
||||||
compose: {
|
compose: {
|
||||||
to: to.value,
|
to: [...to.value],
|
||||||
cc: cc.value,
|
cc: [...cc.value],
|
||||||
bcc: bcc.value,
|
bcc: [...bcc.value],
|
||||||
subject: subject.value,
|
subject: subject.value,
|
||||||
body: body.value,
|
body: body.value,
|
||||||
attachments: attachments.value.map(({ path, filename, size }) => ({ path, filename, size })),
|
attachments: attachments.value.map(({ path, filename, size }) => ({ path, filename, size })),
|
||||||
inReplyTo: session.value.inReplyTo,
|
inReplyTo: sess.inReplyTo,
|
||||||
references: session.value.references,
|
references: sess.references ? [...sess.references] : undefined,
|
||||||
replyToMessageId: session.value.replyToMessageId,
|
replyToMessageId: sess.replyToMessageId,
|
||||||
replyToFolderId: session.value.replyToFolderId
|
replyToFolderId: sess.replyToFolderId
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue