javascript - Send email after successful user registration using meteor js -


i want add email functionality application. have added email package , followed steps according documentation provided

i want when user registers itself, email should sent after successful registration.

here tried:

server/smtp.js:

meteor.startup(function () {   smtp = {     username: 'abc@gmail.com',   // eg: server@gentlenode.com     password: 'abc123',   // eg: 3eep1gtizk5eziohfervu     server:   'smtp.gmail.com',  // eg: mail.gandi.net     port: 25   }    process.env.mail_url = 'smtp://' + encodeuricomponent(smtp.username) + ':' + encodeuricomponent(smtp.password) + '@' + encodeuricomponent(smtp.server) + ':' + smtp.port; }); 

here server/emp_details.js have called methods. following code placed inside meteor.methods():

sendemail: function (to, from, subject, text) {     check([to, from, subject, text], [string]);      // let other method calls same client start running,     // without waiting email sending complete.     this.unblock();      //actual email sending method     email.send({       to: to,       from: from,       subject: subject,       text: text     });   } 

and called method @ client side shown:

template.register.onrendered(function() {     var validator = $('.register').validate({         submithandler: function(event)         {             var email = $('[name=email]').val();             var password = $('[name=password]').val();             var empprofile = session.get('profileimage');             console.log(empprofile);             accounts.createuser({                 email: email,                 password: password,                 profile: {                     name:'test',                     image: empprofile                 },                 function(error)                 {                     if(error)                     {                         if(error.reason == "email exists.")                         {                             validator.showerrors({                                 email: "this email belongs registered user"                             });                         }                     }                     else                     {                         meteor.call('sendemail',                         'alice@example.com',                         'abc@example.com',                         'hello meteor!',                         'this test of email.send.');                         router.go("home");                     }                 }             });         }     }); }); 

i don't know how use email functionality properly.

may suggest alternate solution? add hook accounts.oncreateuser() on server side send email:

accounts.oncreateuser(function (options, user) {     meteor.call(         'sendemail',          'admin@yoursite.com',         user.profile.email, //use path users email in profile         'hello meteor!',         'this test of email.send.'     ); }); 

are using gmail? smtp port google 465 believe, not 25. confirm email sending works outside of meteor using config, , attempt in meteor. believe google limits number of emails sent via smtp 99 per day careful that. if want verify users email address, use built in email verification system in accounts package.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -