refactor(email): set From at transport level instead of per-message
The /settings transport preview shows `from` inside the createTransport JSON, but the implementation was passing it per-message via sendMail. Switch to passing it as part of the transport config so what the preview shows matches what is actually built — no behavioural change for outgoing emails since nodemailer treats transport-level `from` as the default for every sendMail call.
This commit is contained in:
1 parent
e11553c218
commit
baa4d693ae
1 file changed
+4
-4
@@ -127,6 +127,9 @@ export class EmailService implements IEmailService {
|
|||||||
systemEmailRejectUnauthorized,
|
systemEmailRejectUnauthorized,
|
||||||
} = config;
|
} = config;
|
||||||
|
|
||||||
|
const trimmedDisplayName = systemEmailDisplayName?.trim();
|
||||||
|
const from = trimmedDisplayName && systemEmailAddress ? { name: trimmedDisplayName, address: systemEmailAddress } : systemEmailAddress;
|
||||||
|
|
||||||
const emailConfig = {
|
const emailConfig = {
|
||||||
host: systemEmailHost,
|
host: systemEmailHost,
|
||||||
port: Number(systemEmailPort),
|
port: Number(systemEmailPort),
|
||||||
@@ -138,6 +141,7 @@ export class EmailService implements IEmailService {
|
|||||||
name: systemEmailConnectionHost || "localhost",
|
name: systemEmailConnectionHost || "localhost",
|
||||||
connectionTimeout: 5000,
|
connectionTimeout: 5000,
|
||||||
pool: systemEmailPool,
|
pool: systemEmailPool,
|
||||||
|
from,
|
||||||
tls: {
|
tls: {
|
||||||
rejectUnauthorized: systemEmailRejectUnauthorized,
|
rejectUnauthorized: systemEmailRejectUnauthorized,
|
||||||
ignoreTLS: systemEmailIgnoreTLS,
|
ignoreTLS: systemEmailIgnoreTLS,
|
||||||
@@ -159,13 +163,9 @@ export class EmailService implements IEmailService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const trimmedDisplayName = systemEmailDisplayName?.trim();
|
|
||||||
const from = trimmedDisplayName && systemEmailAddress ? { name: trimmedDisplayName, address: systemEmailAddress } : systemEmailAddress;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const info = await this.transporter.sendMail({
|
const info = await this.transporter.sendMail({
|
||||||
to: to,
|
to: to,
|
||||||
from: from,
|
|
||||||
subject: subject,
|
subject: subject,
|
||||||
html: html,
|
html: html,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user