From 593c2b951738f7bf7df7d8a7b9fb271293eb640e Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Mon, 2 Sep 2019 04:42:52 +0900 Subject: [PATCH] Proxy for SMTP (#5371) --- .config/example.yml | 8 ++++++++ src/config/types.ts | 1 + src/services/send-email.ts | 2 ++ 3 files changed, 11 insertions(+) diff --git a/.config/example.yml b/.config/example.yml index 0a62d5ceb..5c1100665 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -130,3 +130,11 @@ autoAdmin: true #syslog: # host: localhost # port: 514 + +# Proxy for HTTP/HTTPS +#proxy: http://127.0.0.1:3128 + +# Proxy for SMTP/SMTPS +#proxySmtp: http://127.0.0.1:3128 # use HTTP/1.1 CONNECT +#proxySmtp: socks4://127.0.0.1:1080 # use SOCKS4 +#proxySmtp: socks5://127.0.0.1:1080 # use SOCKS5 diff --git a/src/config/types.ts b/src/config/types.ts index fbb348fc0..6a3fc3092 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -34,6 +34,7 @@ export type Source = { autoAdmin?: boolean; proxy?: string; + proxySmtp?: string; accesslog?: string; diff --git a/src/services/send-email.ts b/src/services/send-email.ts index 8818c5fcd..5a8f92be5 100644 --- a/src/services/send-email.ts +++ b/src/services/send-email.ts @@ -1,6 +1,7 @@ import * as nodemailer from 'nodemailer'; import { fetchMeta } from '../misc/fetch-meta'; import Logger from './logger'; +import config from '../config'; export const logger = new Logger('email'); @@ -14,6 +15,7 @@ export async function sendEmail(to: string, subject: string, text: string) { port: meta.smtpPort, secure: meta.smtpSecure, ignoreTLS: !enableAuth, + proxy: config.proxySmtp, auth: enableAuth ? { user: meta.smtpUser, pass: meta.smtpPass