mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-03-22 15:46:33 +01:00
📡 feat: Support Unauthenticated SMTP Relays (#12322)
* allow smtp server that does not have authentication * fix: align checkEmailConfig with optional SMTP credentials and add tests Remove EMAIL_USERNAME/EMAIL_PASSWORD requirements from the hasSMTPConfig predicate in checkEmailConfig() so the rest of the codebase (login, startup checks, invite-user) correctly recognizes unauthenticated SMTP as a valid email configuration. Add a warning when only one of the two credential env vars is set, in both sendEmail.js and checkEmailConfig(), to catch partial misconfigurations early. Add test coverage for both the transporter auth assembly in sendEmail.js and the checkEmailConfig predicate in packages/api. Document in .env.example that credentials are optional for unauthenticated SMTP relays. --------- Co-authored-by: Danny Avila <danny@librechat.ai>
This commit is contained in:
parent
28c2e224ae
commit
4e5ae28fa9
5 changed files with 289 additions and 7 deletions
|
|
@ -124,11 +124,20 @@ const sendEmail = async ({ email, subject, payload, template, throwError = true
|
|||
// Whether to accept unsigned certificates
|
||||
rejectUnauthorized: !isEnabled(process.env.EMAIL_ALLOW_SELFSIGNED),
|
||||
},
|
||||
auth: {
|
||||
};
|
||||
|
||||
const hasUsername = !!process.env.EMAIL_USERNAME;
|
||||
const hasPassword = !!process.env.EMAIL_PASSWORD;
|
||||
if (hasUsername && hasPassword) {
|
||||
transporterOptions.auth = {
|
||||
user: process.env.EMAIL_USERNAME,
|
||||
pass: process.env.EMAIL_PASSWORD,
|
||||
},
|
||||
};
|
||||
};
|
||||
} else if (hasUsername !== hasPassword) {
|
||||
logger.warn(
|
||||
'[sendEmail] EMAIL_USERNAME and EMAIL_PASSWORD must both be set for authenticated SMTP, or both omitted for unauthenticated SMTP. Proceeding without authentication.',
|
||||
);
|
||||
}
|
||||
|
||||
if (process.env.EMAIL_ENCRYPTION_HOSTNAME) {
|
||||
// Check the certificate against this name explicitly
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue