Skip to content

Commit

Permalink
allow a MAIL_URL string without auth (#2330)
Browse files Browse the repository at this point in the history
  • Loading branch information
jshimko authored and Aaron Judd committed May 24, 2017
1 parent b5d3952 commit 7c5f24a
Showing 1 changed file with 12 additions and 6 deletions.
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

0 comments on commit 7c5f24a

Please sign in to comment.