mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
move all parameter handling to nodemailer.
This commit is contained in:
parent
8989284e10
commit
efbb17a3b9
3 changed files with 28 additions and 27 deletions
|
@ -15,21 +15,15 @@ client =
|
||||||
logger.log options:options, "Would send email if enabled."
|
logger.log options:options, "Would send email if enabled."
|
||||||
callback()
|
callback()
|
||||||
|
|
||||||
createSesClient = (settings) ->
|
|
||||||
if settings? and settings.key? and settings.key != "" and settings.secret? and settings.secret != ""
|
|
||||||
client = nodemailer.createTransport("SES", {AWSAccessKeyID: settings.key, AWSSecretKey: settings.secret} )
|
|
||||||
else
|
|
||||||
logger.warn "AWS SES credentials are not configured. No emails will be sent."
|
|
||||||
|
|
||||||
if Settings.email?
|
if Settings.email?
|
||||||
switch Settings.email.transport
|
if Settings.email.transport? and Settings.email.parameters?
|
||||||
when "ses"
|
nm_client = nodemailer.createTransport( Settings.email.transport, Settings.email.parameters )
|
||||||
createSesClient( Settings.email.ses)
|
if nm_client
|
||||||
# TODO direct, client
|
client = nm_client
|
||||||
when undefined,null,""
|
|
||||||
logger.warn "No Email transport defined. No emails will be sent."
|
|
||||||
else
|
else
|
||||||
logger.warn "Uknown email transport #{Settings.email.transport}. No emails will be sent."
|
logger.warn "Failed to create email transport. Please check your settings. No email will be sent."
|
||||||
|
else
|
||||||
|
logger.warn "Email transport and/or parameters not defined. No emails will be sent."
|
||||||
|
|
||||||
module.exports =
|
module.exports =
|
||||||
sendEmail : (options, callback = (error) ->)->
|
sendEmail : (options, callback = (error) ->)->
|
||||||
|
@ -39,7 +33,7 @@ module.exports =
|
||||||
to: options.to
|
to: options.to
|
||||||
from: defaultFromAddress
|
from: defaultFromAddress
|
||||||
subject: options.subject
|
subject: options.subject
|
||||||
message: options.html
|
html: options.html
|
||||||
replyTo: options.replyTo || Settings.email.replyToAddress
|
replyTo: options.replyTo || Settings.email.replyToAddress
|
||||||
client.sendMail options, (err, res)->
|
client.sendMail options, (err, res)->
|
||||||
if err?
|
if err?
|
||||||
|
|
|
@ -134,6 +134,22 @@ module.exports =
|
||||||
{name: "English", code: "en"}
|
{name: "English", code: "en"}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Email support
|
||||||
|
# -------------
|
||||||
|
#
|
||||||
|
# ShareLaTeX uses nodemailer (http://www.nodemailer.com/) to send transactional emails.
|
||||||
|
# To see the range of transport and options they support, see http://www.nodemailer.com/docs/transports
|
||||||
|
#email:
|
||||||
|
# fromAddress: ""
|
||||||
|
# replyTo: ""
|
||||||
|
# lifecycle: false
|
||||||
|
## Example transport and parameter settings for Amazon SES
|
||||||
|
# transport: "SES"
|
||||||
|
# parameters:
|
||||||
|
# AWSAccessKeyID: ""
|
||||||
|
# AWSSecretKey: ""
|
||||||
|
|
||||||
|
|
||||||
# Third party services
|
# Third party services
|
||||||
# --------------------
|
# --------------------
|
||||||
#
|
#
|
||||||
|
@ -157,15 +173,6 @@ module.exports =
|
||||||
# tenderUrl: ""
|
# tenderUrl: ""
|
||||||
#
|
#
|
||||||
|
|
||||||
# email:
|
|
||||||
# fromAddress: ""
|
|
||||||
# replyTo: ""
|
|
||||||
# lifecycle: false
|
|
||||||
# ShareLaTeX uses Amazon's SES api to send transactional emails.
|
|
||||||
# Uncomment these lines and provide your credentials to be able to send emails.
|
|
||||||
# ses:
|
|
||||||
# "key":""
|
|
||||||
# "secret":""
|
|
||||||
|
|
||||||
# Production Settings
|
# Production Settings
|
||||||
# -------------------
|
# -------------------
|
||||||
|
|
|
@ -13,9 +13,9 @@ describe "Email", ->
|
||||||
@settings =
|
@settings =
|
||||||
email:
|
email:
|
||||||
transport: "ses"
|
transport: "ses"
|
||||||
ses:
|
parameters:
|
||||||
key: "key"
|
AWSAccessKeyID: "key"
|
||||||
secret: "secret"
|
AWSSecretKey: "secret"
|
||||||
fromAddress: "bob@bob.com"
|
fromAddress: "bob@bob.com"
|
||||||
replyToAddress: "sally@gmail.com"
|
replyToAddress: "sally@gmail.com"
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ describe "Email", ->
|
||||||
|
|
||||||
@sender.sendEmail @opts, =>
|
@sender.sendEmail @opts, =>
|
||||||
args = @sesClient.sendMail.args[0][0]
|
args = @sesClient.sendMail.args[0][0]
|
||||||
args.message.should.equal @opts.html
|
args.html.should.equal @opts.html
|
||||||
args.to.should.equal @opts.to
|
args.to.should.equal @opts.to
|
||||||
args.subject.should.equal @opts.subject
|
args.subject.should.equal @opts.subject
|
||||||
done()
|
done()
|
||||||
|
|
Loading…
Reference in a new issue