verify email using accounts.ui package

后端 未结 3 1342
挽巷
挽巷 2021-02-14 09:45

I want to send a verification email when some user is created. I use the accounts-password package, so any Accounts methods are called in my code.

I read in documentati

3条回答
  •  死守一世寂寞
    2021-02-14 10:38

    You need specify mail in enviroment variables. Then use Accounts.sendVerificationEmail(userId, [email]) in callback of Account.onCreateUser sorry for mistake and delay.

    Like this (below is full example js file):

    Template.register.events({
    'submit #register-form' : function(e, t) {
      e.preventDefault();
      var email = t.find('#account-email').value
        , password = t.find('#account-password').value;
    
        // Trim and validate the input
    
      Accounts.onCreateUser({email: email, password : password}, function(err){
          if (err) {
            // Inform the user that account creation failed
          } else {
            // Success. Account has been created and the user
            // has logged in successfully.
           Accounts.sendVerificationEmail(this.userId, email);
          }
        });
    
      return false;
    }  });
    
    if(Meteor.isServer){
       Meteor.startup(function(){
          process.env.MAIL_URL='smtp://your_mail:your_password@host:port'
       }
    }
    

    I refered to this pages : http://blog.benmcmahen.com/post/41741539120/building-a-customized-accounts-ui-for-meteor

    http://sendgrid.com/blog/send-email-meteor-sendgrid/

    How come my Meteor app with accounts package is not sending a verification email?

提交回复
热议问题