forked from Countly/countly-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[extend] including example of providing/overwriting mail settings
- Loading branch information
1 parent
be13a30
commit c26a156
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
//file should be placed in countly/extend | ||
//edit this script and put it in countly/extend/mail.js to overwrite existing email templates and settings | ||
var nodemailer = require('nodemailer'); | ||
var smtpTransport = require('nodemailer-smtp-transport'); | ||
|
||
//rename company | ||
var company = "Company"; | ||
var email = "email@company.com"; | ||
|
||
module.exports = function(mail){ | ||
//define this if you need to send email from some third party service | ||
mail.smtpTransport = nodemailer.createTransport(smtpTransport({ | ||
host: "myhost", | ||
secureConnection: true, | ||
port: 2525, | ||
auth: { | ||
user: "username", | ||
pass: "password" | ||
} | ||
})); | ||
|
||
mail.sendMessage = function (to, subject, message, callback) { | ||
mail.sendMail({ | ||
to:to, | ||
from:company+" <"+email+">", | ||
subject:subject || "", | ||
html:message || "" | ||
}, callback); | ||
}; | ||
|
||
mail.sendToNewMember = function (member, memberPassword) { | ||
mail.lookup(function(err, host) { | ||
mail.sendMessage(member.email, "Your "+company+" Account", | ||
"Hi "+mail.getUserFirstName(member)+",<br/><br/>Your "+company+" account on <a href='"+host+"'>"+host+"</a> is created with the following details;<br/><br/>Username: "+member.username+"<br/>Password: "+memberPassword+"<br/><br/>Enjoy,<br/>A fellow "+company+" Admin"); | ||
}); | ||
}; | ||
|
||
mail.sendToUpdatedMember = function (member, memberPassword) { | ||
mail.lookup(function(err, host) { | ||
mail.sendMessage(member.email, ""+company+" Account - Password Change", "Hi "+mail.getUserFirstName(member)+",<br/><br/>Your password for your "+company+" account on <a href='"+host+"'>"+host+"</a> has been changed. Below you can find your updated account details;<br/><br/>Username: "+member.username+"<br/>Password: "+memberPassword+"<br/><br/>Best,<br/>A fellow "+company+" Admin"); | ||
}); | ||
}; | ||
|
||
mail.sendPasswordResetInfo = function (member, prid) { | ||
mail.lookup(function(err, host) { | ||
mail.sendMessage(member.email, ""+company+" Account - Password Reset", "Hi "+mail.getUserFirstName(member)+",<br/><br/>You can reset your "+company+" account password by following <a href='"+host+"/reset/"+prid+"'>this link</a>.<br/><br/>If you did not request to reset your password ignore this email.<br/><br/>Best,<br/>A fellow "+company+" Admin"); | ||
}); | ||
}; | ||
}; |