Skip to content

Commit c26a156

Browse files
committed
[extend] including example of providing/overwriting mail settings
1 parent be13a30 commit c26a156

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

extend/mail.example.js

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//file should be placed in countly/extend
2+
//edit this script and put it in countly/extend/mail.js to overwrite existing email templates and settings
3+
var nodemailer = require('nodemailer');
4+
var smtpTransport = require('nodemailer-smtp-transport');
5+
6+
//rename company
7+
var company = "Company";
8+
var email = "[email protected]";
9+
10+
module.exports = function(mail){
11+
//define this if you need to send email from some third party service
12+
mail.smtpTransport = nodemailer.createTransport(smtpTransport({
13+
host: "myhost",
14+
secureConnection: true,
15+
port: 2525,
16+
auth: {
17+
user: "username",
18+
pass: "password"
19+
}
20+
}));
21+
22+
mail.sendMessage = function (to, subject, message, callback) {
23+
mail.sendMail({
24+
to:to,
25+
from:company+" <"+email+">",
26+
subject:subject || "",
27+
html:message || ""
28+
}, callback);
29+
};
30+
31+
mail.sendToNewMember = function (member, memberPassword) {
32+
mail.lookup(function(err, host) {
33+
mail.sendMessage(member.email, "Your "+company+" Account",
34+
"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");
35+
});
36+
};
37+
38+
mail.sendToUpdatedMember = function (member, memberPassword) {
39+
mail.lookup(function(err, host) {
40+
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");
41+
});
42+
};
43+
44+
mail.sendPasswordResetInfo = function (member, prid) {
45+
mail.lookup(function(err, host) {
46+
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");
47+
});
48+
};
49+
};

0 commit comments

Comments
 (0)