流星邮件不发送,尽管制定MAIL_URL环境变量(Meteor mail not sending d

2019-10-22 22:15发布

我在终端收到此错误信息“的邮件没有发送,使发送,设置MAIL_URL环境变量”。 尽管设置MAIL_URL环境变量。 这个消息后整个邮件内容HTML在终端被倾倒。 我使用的是2个流星包发送电子邮件:yogiben:漂亮,电子邮件和电子邮件mailgun API服务。

以下是邮件的配置和发送电子邮件的源代码:

if Meteor.isServer
    Meteor.startup ->
        process.env.MAIL_URL = 'smtp://sandboxid.mailgun.org:mypassword@smtp.mailgun.org:587'
        return


    PrettyEmail.options = 
        from: 'primaryemail@gmail.com'

        siteName: 'Meteor Test'
        companyAddress: 'sdfsf, gdfg-df'
        companyName: 'Code to Create'
        companyUrl: 'http://example.com'

    Accounts.sendVerificationEmail ->
        Meteor.userId()

该文件保存Project_Directory /都/ _config目录内。 我目前正在开发本地Ubuntu的服务器上的这个程序。

Answer 1:

我想调用sendVerificationEmail应该是:

Accounts.sendVerificationEmail Meteor.userId()

按照该文档在http://docs.meteor.com/#/full/accounts_sendverificationemail

如果代码是你使用的确切的代码,那么你可能是具有,因为其中每一段代码运行(回调异步运行)的顺序问题。 启动回调后运行PrettyEmail.optionsAccounts.sendVerificationEmail

如果缩进的两个部分,如下它应该按预期工作:

if Meteor.isServer
    Meteor.startup ->
        process.env.MAIL_URL = 'smtp://sandboxid.mailgun.org:mypassword@smtp.mailgun.org:587'

        PrettyEmail.options = 
            from: 'primaryemail@gmail.com'
            siteName: 'Meteor Test'
            companyAddress: 'sdfsf, gdfg-df'
            companyName: 'Code to Create'
            companyUrl: 'http://example.com'

        Accounts.sendVerificationEmail Meteor.userId()

如果做不到这一点,也可能是值得设置MAIL_URL运行的应用程序,例如之前:

MAIL_URL="smtp://sandboxid.mailgun.org:mypassword@smtp.mailgun.org:587" meteor

编辑: 您的代码示例是不安全的:如果你是在“两个”目录保持此代码,那么任何人访问你的网站就可以看到你的mailgun凭据。 你应该把服务器代码在“服务器”目录或至少是设置你的代码外MAIL_URL如上图所示。



Answer 2:

我碰到了同样的错误。 诀窍是不包括在应用程序中MAIL_URL,但在终端,你运行流星本身。

使用下面的命令来运行流星:

MAIL_URL = “SMTP://postmaster@sandbox****.mailgun.org:XXXX@smtp.mailgun.org:587” 流星

我想这对Ubuntu的终端,因此应在Mac上正常工作。



文章来源: Meteor mail not sending despite setting MAIL_URL environment variable