-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendAccountEmailMandrill.js
49 lines (41 loc) · 1.23 KB
/
sendAccountEmailMandrill.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Send a verification email through Mandrill when a new user signs up
if (Meteor.isServer) {
Meteor.startup(function () {
Accounts.emailTemplates.verifyEmail.html = function (user, url) {
var result;
try {
result = Mandrill.templates.render({
template_name: 'email-confirm',
template_content: [
{
name: 'body',
content: 'confirm email: ' + url
},
],
merge_vars: [
{
name: 'USERFIRSTNAME',
content: "USER" // you could pull user.profile.firstName if they added it
},
{
name: 'CONFIRMURL',
content: url
}
]
});
} catch (error) {
console.error('Error while rendering Mandrill template', error);
}
return result.data.html;
}
});
Accounts.onCreateUser(function(options, user) {
console.log("new user");
user.profile = {};
// we wait for Meteor to create the user before sending an email
Meteor.setTimeout(function() {
Accounts.sendVerificationEmail(user._id);
}, 2 * 1000);
return user;
});
}