diff --git a/services/web/app/coffee/Features/Email/EmailSender.coffee b/services/web/app/coffee/Features/Email/EmailSender.coffee index ff34d9d60e..abaaf80a71 100644 --- a/services/web/app/coffee/Features/Email/EmailSender.coffee +++ b/services/web/app/coffee/Features/Email/EmailSender.coffee @@ -20,10 +20,10 @@ module.exports = metrics.inc "email" options = to: options.to - from: "ShareLaTeX " + from: Settings.email.fromAddress subject: options.subject message: options.html - replyTo: options.replyTo || "team@sharelatex.com" + replyTo: Settings.email.replyToAddress client.sendemail options, (err, data, res)-> if err? logger.err err:err, "error sending message" diff --git a/services/web/test/UnitTests/coffee/Email/EmailSenderTests.coffee b/services/web/test/UnitTests/coffee/Email/EmailSenderTests.coffee index 179f704dcc..a12d66781b 100644 --- a/services/web/test/UnitTests/coffee/Email/EmailSenderTests.coffee +++ b/services/web/test/UnitTests/coffee/Email/EmailSenderTests.coffee @@ -10,10 +10,14 @@ describe "Email", -> beforeEach -> - @settings = - ses: - key: "key" - secret: "secret" + @settings = + email: + ses: + key: "key" + secret: "secret" + fromAddress: "bob@bob.com" + replyToAddress: "sally@gmail.com" + @sesClient = sendemail: sinon.stub() @ses = @@ -26,21 +30,22 @@ describe "Email", -> warn:-> err:-> + @opts = + to: "bob@bob.com" + subject: "new email" + html: "" + replyTo: "sarah@bob.com" + describe "sendEmail", -> it "should set the properties on the email to send", (done)-> @sesClient.sendemail.callsArgWith(1) - opts = - to: "bob@bob.com" - subject: "new email" - html: "" - replyTo: "sarah@bob.com" - @sender.sendEmail opts, => + @sender.sendEmail @opts, => args = @sesClient.sendemail.args[0][0] - args.message.should.equal opts.html - args.to.should.equal opts.to - args.subject.should.equal opts.subject + args.message.should.equal @opts.html + args.to.should.equal @opts.to + args.subject.should.equal @opts.subject done() it "should return the error", (done)-> @@ -48,3 +53,21 @@ describe "Email", -> @sender.sendEmail {}, (err)=> err.should.equal "error" done() + + + it "should use the from address from settings", (done)-> + @sesClient.sendemail.callsArgWith(1) + + @sender.sendEmail @opts, => + args = @sesClient.sendemail.args[0][0] + args.from.should.equal @settings.email.fromAddress + done() + + it "should use the reply to address from settings", (done)-> + @sesClient.sendemail.callsArgWith(1) + + @sender.sendEmail @opts, => + args = @sesClient.sendemail.args[0][0] + args.replyTo.should.equal @settings.email.replyToAddress + done() +