簡體   English   中英

SMTP服務器出現錯誤。 郵件未在Meteor App中發送

[英]SMTP server giving error. Mails not being sent in Meteor App

我正在閱讀《流星在行動》一書,並且正在制作一個簡單的應用程序,該應用程序要求SMTP服務器能夠在注冊時發送電子郵件驗證。

我遵循了所有步驟,但似乎不正確。 正在創建用戶,但未發送驗證郵件,實際上,正在引發錯誤:

I20150128-16:16:53.221(5.5)? Exception in setTimeout callback: Error: connect ETIMEDOUT
I20150128-16:16:53.225(5.5)?     at Object.Future.wait (/Users/niranjan/.meteor/packages/meteor-tool/.1.0.40.i0mc94++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:326:15)
I20150128-16:16:53.225(5.5)?     at smtpSend (packages/email/email.js:91:1)
I20150128-16:16:53.226(5.5)?     at Object.Email.send (packages/email/email.js:168:1)
I20150128-16:16:53.226(5.5)?     at Object.Accounts.sendVerificationEmail (packages/accounts-password/password_server.js:602:1)
I20150128-16:16:53.226(5.5)?     at app/server/server.js:10:16
I20150128-16:16:53.227(5.5)?     at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
I20150128-16:16:53.227(5.5)?     at packages/meteor/timers.js:6:1
I20150128-16:16:53.227(5.5)?     at runWithEnvironment (packages/meteor/dynamics_nodejs.js:108:1)
I20150128-16:16:53.227(5.5)?     - - - - -
I20150128-16:16:53.227(5.5)?     at errnoException (net.js:904:11)
I20150128-16:16:53.228(5.5)?     at Object.afterConnect [as oncomplete] (net.js:895:19)

我一直在嘗試調試它,但似乎無法弄清楚發生了什么。

以下是相關代碼-client / templates.html:

  Accounts.onCreateUser(function (options, user) {
      if (options.profile) {
        user.profile = options.profile;
      } else {
        user.profile = "White belt";
      }
      user.profile.rank = "White belt";
      if(options.email) {
        Meteor.setTimeout(function () {
          Accounts.sendVerificationEmail(user._id);  // I think this is the error source
        }, 2 * 1000 );
      }
      return user;
    });

服務器/smtp.js:

Meteor.startup(function () {
  smtp = {
    username: 'myemail@gmail.com',
    password: 'mysecretpassword',
    servre: 'smtp.gmail.com',
    port: 587
  };
  process.env.MAIL_URL = 'smtp://' + 
      encodeURIComponent(smtp.username) + ':' + 
      encodeURIComponent(smtp.password) + '@' +
      encodeURIComponent(smtp.server) + ':' +
      smtp.port;
});

Accounts.emailTemplates.siteName = "Meteor in Action userApp";
Accounts.emailTemplates.from = "Name <myemail@gmail.com>";

Accounts.emailTemplates.verifyEmail.subject = function (user) {
  return 'Confirm your email address, ' + user.username;
};

Accounts.emailTemplates.verifyEmail.text = function (user, url) {
  return 'Welcome to the Meteor in Action userApp! \n'
    + 'To veryify - \n' + url;
};

Accounts.emailTemplates.verifyEmail.html = function (user, url) {
  return "<h1>Welcome to the Meteor in Action userApp! </h1>"
    + "<p>To verify - </p>" + url;
};

我的朋友,問題出在您拼錯了世界服務器的server/smtp.js文件中。 因此smtp對象沒有任何稱為server屬性。 您定義為servre

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM