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."
|
||||
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?
|
||||
switch Settings.email.transport
|
||||
when "ses"
|
||||
createSesClient( Settings.email.ses)
|
||||
# TODO direct, client
|
||||
when undefined,null,""
|
||||
logger.warn "No Email transport defined. No emails will be sent."
|
||||
if Settings.email.transport? and Settings.email.parameters?
|
||||
nm_client = nodemailer.createTransport( Settings.email.transport, Settings.email.parameters )
|
||||
if nm_client
|
||||
client = nm_client
|
||||
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 =
|
||||
sendEmail : (options, callback = (error) ->)->
|
||||
|
@ -39,7 +33,7 @@ module.exports =
|
|||
to: options.to
|
||||
from: defaultFromAddress
|
||||
subject: options.subject
|
||||
message: options.html
|
||||
html: options.html
|
||||
replyTo: options.replyTo || Settings.email.replyToAddress
|
||||
client.sendMail options, (err, res)->
|
||||
if err?
|
||||
|
|
|
@ -134,6 +134,22 @@ module.exports =
|
|||
{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
|
||||
# --------------------
|
||||
#
|
||||
|
@ -157,15 +173,6 @@ module.exports =
|
|||
# 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
|
||||
# -------------------
|
||||
|
|
|
@ -13,9 +13,9 @@ describe "Email", ->
|
|||
@settings =
|
||||
email:
|
||||
transport: "ses"
|
||||
ses:
|
||||
key: "key"
|
||||
secret: "secret"
|
||||
parameters:
|
||||
AWSAccessKeyID: "key"
|
||||
AWSSecretKey: "secret"
|
||||
fromAddress: "bob@bob.com"
|
||||
replyToAddress: "sally@gmail.com"
|
||||
|
||||
|
@ -43,7 +43,7 @@ describe "Email", ->
|
|||
|
||||
@sender.sendEmail @opts, =>
|
||||
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.subject.should.equal @opts.subject
|
||||
done()
|
||||
|
|
Loading…
Reference in a new issue