2016-10-17 214 views
0

我已經創建了幫助程序和事件以便忘記密碼,並且我已經編寫了聯繫人電子郵件的代碼,並且代碼運行成功並且能夠發送電子郵件,但是我想使用電子郵件模板。我做了一個驗證電子郵件,使用一個電子郵件模板,使用名爲的程序包「meteor add meteorhacks:ssr」重置密碼電子郵件模板

這裏是我寫和PLZ幫我

 Template.recoverPassword.events({ 
      'submit #recovery-form':function(e,t){ 
       e.preventDefault(); 
       var email= t.find('#recovery-email').value; 
       Accounts.forgotPassword({email: email},function(error){ 
        if(error){ 
         alert("unable to send reset link"); 
        } 
        else{ 
         alert("password reset link sent"); 
        } 
       }); 

我已經寫方法在服務器端發送電子郵件,如下methods.js

Meteor.methods({ 

     'sendEmail' :function(from,phone,fname,subj,body){ 
     this.unblock(); 
     Email.send({ 
      to:'[email protected]', 
      from:from, 
      subject:subj, 
      text:phone, 
      text:fname, 
      text:body, 
      html: SSR.render('contactbody', sendEmail) 
     }) 
     }, 

代碼請向我建議如何爲忘記密碼和聯繫電子郵件添加電子郵件模板。我已經嘗試過使用ssr包在私人文件夾下創建一個電子郵件正文,並試圖插入服務器端,但它不工作,但等待尋求幫助!請告訴我如何處理。

+0

Hi @shivani,什麼是聯繫郵件? –

+0

用戶可以發送電子郵件,如果他有任何關於網站的查詢..因爲我已經創建了一個聯繫表格,就好像現在正常的電子郵件沒有任何設計工作我想插入電子郵件模板。 – Shivani

回答

0

要發送重置密碼電子郵件

Accounts.emailTemplates.resetPassword.html = function (user, url) { 
     SSR.compileTemplate('registartionEmail', Assets.getText('email_templates/registration_confirm.html')); 
     var emailData = { 
       x: y; 
     }; 
     return SSR.render('registartionEmail', emailData); 
}; 

發送郵件聯繫

克林特方:您可以使用任何編輯器來從用戶寫郵件。您還可以使用{{用戶名}},{{日期}}等一些類似的功能將郵件發送給用戶表單管理員。

而在提交事件你可以調用服務器方法。

Meteor.call('sendEmail', 
      '[email protected]', 
      Meteor.user().emails[0].address, 
      'Hello from Meteor!', 
      'This is a test of Email.send.'); 

服務器端:

你可以,如果你在你的郵件正文的HTML /文本使用spacbar使用SSR。

Meteor.methods({ 
    sendEmail: function (to, from, subject, text) { 
    check([to, from, subject, text], [String]); 
    // Let other method calls from the same client start running, 
    // without waiting for the email sending to complete. 
    this.unblock(); 
    Email.send({ 
     to: to, 
     from: from, 
     subject: subject, 
     text: SSR.render("text", {username: "Pankaj"}) 
    }); 
    } 
}); 
+0

你沒有得到什麼?你能否讓你的觀點更清楚?我無法理解你的觀點。 –