diff --git a/src/mail.js b/src/mail.js index c61b681e1..9628b5394 100644 --- a/src/mail.js +++ b/src/mail.js @@ -908,7 +908,7 @@ function addMailbox(name, domain, userId, callback) { if (error) return callback(error); mailboxdb.addMailbox(name, domain, userId, mailboxdb.TYPE_USER, function (error) { - if (error && error.reason === DatabaseError.ALREADY_EXISTS) return callback(new MailError(MailError.ALREADY_EXISTS, 'mailbox already exists')); + if (error && error.reason === DatabaseError.ALREADY_EXISTS) return callback(new MailError(MailError.ALREADY_EXISTS, `mailbox ${name} already exists`)); if (error) return callback(new MailError(MailError.INTERNAL_ERROR, error)); callback(null); diff --git a/src/routes/mail.js b/src/routes/mail.js index 23e763290..005a3d759 100644 --- a/src/routes/mail.js +++ b/src/routes/mail.js @@ -232,7 +232,7 @@ function addMailbox(req, res, next) { mail.addMailbox(req.body.name, req.params.domain, req.body.userId, function (error) { if (error && error.reason === MailError.NOT_FOUND) return next(new HttpError(404, error.message)); - if (error && error.reason === MailError.ALREADY_EXISTS) return next(new HttpSuccess(201, {})); + if (error && error.reason === MailError.ALREADY_EXISTS) return next(new HttpError(409, error.message)); if (error && error.reason === MailError.BAD_FIELD) return next(new HttpError(400, error.message)); if (error) return next(new HttpError(500, error));