Skip to content

feat: support standalone mail smtp from field #531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"mongodb": "^5.9.2",
"multer": "1.4.5-lts.1",
"node-fetch": "^3.3.0",
"nodemailer": "^6.9.9",
"nodemailer": "^6.9.13",
"request-ip": "^3.3.0",
"socks-proxy-agent": "^7.0.0",
"speakeasy": "^2.0.0",
Expand Down
28 changes: 17 additions & 11 deletions service/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion service/src/storage/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ export async function getOriginConfig() {
!Number.isNaN(+process.env.SMTP_PORT) ? +process.env.SMTP_PORT : 465,
process.env.SMTP_TSL === 'true',
process.env.SMTP_USERNAME,
process.env.SMTP_PASSWORD))
process.env.SMTP_PASSWORD,
process.env.SMTP_FROM || process.env.SMTP_USERNAME,
),
)
}
else {
if (config.siteConfig.loginEnabled === undefined)
Expand Down
1 change: 1 addition & 0 deletions service/src/storage/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ export class MailConfig {
public smtpTsl: boolean,
public smtpUserName: string,
public smtpPassword: string,
public smtpFrom?: string,
) { }
}

Expand Down
2 changes: 1 addition & 1 deletion service/src/utils/mail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export async function sendTestMail(toMail: string, config: MailConfig) {

async function sendMail(toMail: string, subject: string, html: string, config: MailConfig) {
const mailOptions = {
from: config.smtpUserName,
from: config.smtpFrom || config.smtpUserName,
to: toMail,
subject,
html,
Expand Down
9 changes: 9 additions & 0 deletions src/components/common/Setting/Mail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ onMounted(() => {
/>
</div>
</div>
<div class="flex items-center space-x-4">
<span class="flex-shrink-0 w-[100px]">{{ $t('setting.smtpFrom') }}</span>
<div class="flex-1">
<NInput
:value="config && config.smtpFrom" placeholder=""
@input="(val) => { if (config) config.smtpFrom = val }"
/>
</div>
</div>
<div class="flex items-center space-x-4">
<span class="flex-shrink-0 w-[100px]" />
<div class="flex flex-wrap items-center gap-4">
Expand Down
1 change: 1 addition & 0 deletions src/components/common/Setting/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class MailConfig {
smtpTsl?: boolean
smtpUserName?: string
smtpPassword?: string
smtpFrom?: string
}
export type TextAuditServiceProvider = 'baidu' // | 'ali'

Expand Down
1 change: 1 addition & 0 deletions src/locales/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export default {
smtpTsl: 'Tsl',
smtpUserName: 'UserName',
smtpPassword: 'Password',
smtpFrom: 'From',
siteTitle: 'Title',
siteDomain: 'Domain',
registerEnabled: 'Register Enabled',
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export default {
smtpTsl: 'Tsl',
smtpUserName: '账号',
smtpPassword: '密码/专用密码',
smtpFrom: '发件人邮箱',
siteTitle: '网站标题',
siteDomain: '域名 不含/',
registerEnabled: '新用户',
Expand Down
Loading