add support for transactional html/text emails
- Add support for welcome email on user creation (both OAuth and password users) - Add support for html/text templating on verify email. - Add support for html/text templating on reset password. - Add handlers for converting Handlebars templates to HTML and text (template agnostic). - Add helper function sendEmail() for compiling and sending templates via Email.send() (SMTP).
This commit is contained in:
parent
aa14a26bba
commit
379f7dcd76
17 changed files with 2234 additions and 804 deletions
|
|
@ -5,7 +5,7 @@ import editProfile from './edit-profile';
|
|||
import rateLimit from '../../../modules/rate-limit';
|
||||
|
||||
Meteor.methods({
|
||||
'users.sendVerificationEmail': function usersResendVerification() {
|
||||
'users.sendVerificationEmail': function usersSendVerificationEmail() {
|
||||
return Accounts.sendVerificationEmail(this.userId);
|
||||
},
|
||||
'users.editProfile': function usersEditProfile(profile) {
|
||||
|
|
|
|||
25
imports/api/Users/server/send-welcome-email.js
Normal file
25
imports/api/Users/server/send-welcome-email.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import sendEmail from '../../../modules/server/send-email';
|
||||
import getOAuthProfile from '../../../modules/get-oauth-profile';
|
||||
|
||||
export default (options, user) => {
|
||||
const OAuthProfile = getOAuthProfile(options, user);
|
||||
|
||||
const applicationName = 'Application Name';
|
||||
const firstName = OAuthProfile ? OAuthProfile.name.first : options.profile.name.first;
|
||||
const emailAddress = OAuthProfile ? OAuthProfile.email : options.email;
|
||||
|
||||
return sendEmail({
|
||||
to: emailAddress,
|
||||
from: `${applicationName} <support@application.com>`,
|
||||
subject: `[${applicationName}] Welcome, ${firstName}!`,
|
||||
template: 'welcome',
|
||||
templateVars: {
|
||||
applicationName,
|
||||
firstName,
|
||||
welcomeUrl: Meteor.absoluteUrl('documents'), // e.g., returns http://localhost:3000/documents
|
||||
},
|
||||
})
|
||||
.catch((error) => {
|
||||
throw new Meteor.Error('500', `${error}`);
|
||||
});
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue