Init (#2405)
This commit is contained in:
@@ -595,13 +595,13 @@ export class CommentService implements OnModuleInit {
|
||||
type: CommentReplyMailType
|
||||
}) {
|
||||
const { seo, mailOptions } = await this.configsService.waitForConfigReady()
|
||||
const { user } = mailOptions
|
||||
const from = `"${seo.title || 'Mx Space'}" <${user}>`
|
||||
const { from, user } = mailOptions
|
||||
const sendfrom = `"${seo.title || 'Mx Space'}" <${from || user}>`
|
||||
|
||||
source.ip ??= ''
|
||||
if (type === CommentReplyMailType.Guest) {
|
||||
const options = {
|
||||
from,
|
||||
from: sendfrom,
|
||||
subject: `[${seo.title || 'Mx Space'}] 主人给你了新的回复呐`,
|
||||
to,
|
||||
html: render(
|
||||
@@ -619,7 +619,7 @@ export class CommentService implements OnModuleInit {
|
||||
await this.mailService.send(options)
|
||||
} else {
|
||||
const options = {
|
||||
from,
|
||||
from: sendfrom,
|
||||
subject: `[${seo.title || 'Mx Space'}] 有新回复了耶~`,
|
||||
to,
|
||||
html: render(
|
||||
|
||||
@@ -19,6 +19,7 @@ export const generateDefaultConfig: () => IConfig = () => ({
|
||||
|
||||
user: '',
|
||||
pass: '',
|
||||
from: '',
|
||||
options: {
|
||||
host: '',
|
||||
port: 465,
|
||||
|
||||
@@ -83,11 +83,11 @@ class MailOption {
|
||||
@IsInt()
|
||||
@Transform(({ value: val }) => Number.parseInt(val))
|
||||
@IsOptional()
|
||||
@JSONSchemaNumberField('发件邮箱端口', halfFieldOption)
|
||||
@JSONSchemaNumberField('SMTP 端口', halfFieldOption)
|
||||
port: number
|
||||
@IsUrl({ require_protocol: false })
|
||||
@IsOptional()
|
||||
@JSONSchemaHalfGirdPlainField('发件邮箱 host')
|
||||
@JSONSchemaHalfGirdPlainField('SMTP 主机')
|
||||
host: string
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
@@ -103,11 +103,15 @@ export class MailOptionsDto {
|
||||
@IsEmail()
|
||||
@IsOptional()
|
||||
@JSONSchemaHalfGirdPlainField('发件邮箱地址')
|
||||
from: string
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
@JSONSchemaHalfGirdPlainField('SMTP 用户名')
|
||||
user: string
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsOptional()
|
||||
@JSONSchemaPasswordField('发件邮箱密码', halfFieldOption)
|
||||
@JSONSchemaPasswordField('SMTP 密码', halfFieldOption)
|
||||
@SecretField
|
||||
pass: string
|
||||
|
||||
|
||||
@@ -195,10 +195,10 @@ export class LinkService {
|
||||
template: LinkApplyEmailType
|
||||
}) {
|
||||
const { seo, mailOptions } = await this.configsService.waitForConfigReady()
|
||||
const { user } = mailOptions
|
||||
const from = `"${seo.title || 'Mx Space'}" <${user}>`
|
||||
const { from, user } = mailOptions
|
||||
const sendfrom = `"${seo.title || 'Mx Space'}" <${from || user}>`
|
||||
await this.emailService.getInstance().sendMail({
|
||||
from,
|
||||
from: sendfrom,
|
||||
to,
|
||||
subject:
|
||||
template === LinkApplyEmailType.ToMaster
|
||||
@@ -278,10 +278,10 @@ export class LinkService {
|
||||
return
|
||||
}
|
||||
|
||||
const { user } = mailOptions
|
||||
const from = `"${seo.title || 'Mx Space'}" <${user}>`
|
||||
const { from, user } = mailOptions
|
||||
const sendfrom = `"${seo.title || 'Mx Space'}" <${from || user}>`
|
||||
await this.emailService.getInstance().sendMail({
|
||||
from,
|
||||
from: sendfrom,
|
||||
to: doc.email,
|
||||
subject: `嘿!~, 主人已处理你的友链申请!~`,
|
||||
text: `申请结果:${LinkStateMap[state]}\n原因:${reason}`,
|
||||
|
||||
@@ -258,8 +258,8 @@ export class SubscribeService implements OnModuleInit, OnModuleDestroy {
|
||||
unsubscribeLink: string,
|
||||
) {
|
||||
const { seo, mailOptions } = await this.configService.waitForConfigReady()
|
||||
const { user } = mailOptions
|
||||
const from = `"${seo.title || 'Mx Space'}" <${user}>`
|
||||
const { from, user } = mailOptions
|
||||
const sendfrom = `"${seo.title || 'Mx Space'}" <${from || user}>`
|
||||
let finalTemplate = ''
|
||||
|
||||
const cacheKey = 'template'
|
||||
@@ -275,7 +275,7 @@ export class SubscribeService implements OnModuleInit, OnModuleDestroy {
|
||||
}
|
||||
|
||||
const options: Mail.Options = {
|
||||
from,
|
||||
from: sendfrom,
|
||||
...{
|
||||
subject: `[${seo.title || 'Mx Space'}] 发布了新内容~`,
|
||||
to: email,
|
||||
|
||||
@@ -159,7 +159,7 @@ export class EmailService implements OnModuleInit, OnModuleDestroy {
|
||||
const master = await this.userService.getMaster()
|
||||
const mailOptions = await this.configsService.get('mailOptions')
|
||||
return this.instance.sendMail({
|
||||
from: `"Mx Space" <${mailOptions.user}>`,
|
||||
from: `"Mx Space" <${mailOptions.from || mailOptions.user}>`,
|
||||
to: master.mail,
|
||||
subject: '测试邮件',
|
||||
text: '这是一封测试邮件',
|
||||
|
||||
Reference in New Issue
Block a user