mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00

* feat(email): replace 'Enable SSL' setting with more descriptive/clear 'Encryption Method' setting * fix: clarify settings & add true 'none' option
57 lines
1.5 KiB
TypeScript
57 lines
1.5 KiB
TypeScript
import Email from 'email-templates';
|
|
import nodemailer from 'nodemailer';
|
|
import { URL } from 'url';
|
|
import { getSettings, NotificationAgentEmail } from '../settings';
|
|
import { openpgpEncrypt } from './openpgpEncrypt';
|
|
|
|
class PreparedEmail extends Email {
|
|
public constructor(settings: NotificationAgentEmail, pgpKey?: string) {
|
|
const { applicationUrl } = getSettings().main;
|
|
|
|
const transport = nodemailer.createTransport({
|
|
name: applicationUrl ? new URL(applicationUrl).hostname : undefined,
|
|
host: settings.options.smtpHost,
|
|
port: settings.options.smtpPort,
|
|
secure: settings.options.secure,
|
|
ignoreTLS: settings.options.ignoreTls,
|
|
requireTLS: settings.options.requireTls,
|
|
tls: settings.options.allowSelfSigned
|
|
? {
|
|
rejectUnauthorized: false,
|
|
}
|
|
: undefined,
|
|
auth:
|
|
settings.options.authUser && settings.options.authPass
|
|
? {
|
|
user: settings.options.authUser,
|
|
pass: settings.options.authPass,
|
|
}
|
|
: undefined,
|
|
});
|
|
|
|
if (pgpKey) {
|
|
transport.use(
|
|
'stream',
|
|
openpgpEncrypt({
|
|
signingKey: settings.options.pgpPrivateKey,
|
|
password: settings.options.pgpPassword,
|
|
encryptionKeys: [pgpKey],
|
|
})
|
|
);
|
|
}
|
|
|
|
super({
|
|
message: {
|
|
from: {
|
|
name: settings.options.senderName,
|
|
address: settings.options.emailFrom,
|
|
},
|
|
},
|
|
send: true,
|
|
transport: transport,
|
|
});
|
|
}
|
|
}
|
|
|
|
export default PreparedEmail;
|