Skip to content
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

allow a MAIL_URL string without auth #2330

Merged
merged 2 commits into from
May 24, 2017
Merged
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
18 changes: 12 additions & 6 deletions server/api/core/email/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,29 @@ export function getMailConfig() {
if (mailString) {
// parse the url
const parsedUrl = url.parse(mailString);
const creds = parsedUrl.auth.split(":");
const creds = !!parsedUrl.auth && parsedUrl.auth.split(":");
parsedUrl.port = Number(parsedUrl.port);

Logger.debug(`Using ${parsedUrl.hostname} to send email`);

// create a nodemailer config from the SMTP url string
return {
const config = {
host: parsedUrl.hostname,
port: parsedUrl.port,
// since the port is casted to number above
secure: parsedUrl.port === 465,
auth: {
user: creds[0],
pass: creds[1]
},
logger: process.env.EMAIL_DEBUG === "true"
};

// add user/pass to the config object if they were found
if (!!creds) {
config.auth = {
user: creds[0],
pass: creds[1]
};
}

return config;
}

// check for mail settings in the database
Expand Down