Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/429.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Meteor邮件未发送,尽管设置了mail_URL环境变量_Javascript_Email_Meteor_Coffeescript - Fatal编程技术网

Javascript Meteor邮件未发送,尽管设置了mail_URL环境变量

Javascript Meteor邮件未发送,尽管设置了mail_URL环境变量,javascript,email,meteor,coffeescript,Javascript,Email,Meteor,Coffeescript,我在终端“Mail not sent;要启用发送,请设置Mail_URL环境变量”中收到此错误消息。尽管设置了Mail_URL环境变量。在该消息之后,整个邮件内容html将转储到终端中。我使用2个meteor软件包发送电子邮件:yogiben:pretty电子邮件和带有mailgun api服务的电子邮件 以下是邮件配置和发送电子邮件的源代码: if Meteor.isServer Meteor.startup -> process.env.MAIL_URL = '

我在终端“Mail not sent;要启用发送,请设置Mail_URL环境变量”中收到此错误消息。尽管设置了Mail_URL环境变量。在该消息之后,整个邮件内容html将转储到终端中。我使用2个meteor软件包发送电子邮件:yogiben:pretty电子邮件和带有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\u目录/both/\u config目录中。我目前正在本地ubuntu服务器上开发此应用程序。

我认为调用
sendVerificationEmail
应该是:

Accounts.sendVerificationEmail Meteor.userId()
根据

如果该代码正是您正在使用的代码,那么您可能会遇到问题,因为每段代码的运行顺序(回调异步运行)。启动回调将在
PrettyEmail.options
Accounts.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\u URL
也可能是值得的,例如:

MAIL_URL="smtp://sandboxid.mailgun.org:mypassword@smtp.mailgun.org:587" meteor
编辑:
您的示例代码不安全:如果您将此代码保存在“两者”目录中,则任何访问您网站的人都可以看到您的邮枪凭据。您应该将服务器代码放在“server”目录中,或者至少在代码之外设置邮件URL,如上所示。

我遇到了相同的错误。诀窍是在应用程序中不包括MAIL_URL,而是在运行meteor本身的终端中

使用以下命令运行meteor:

邮件地址=”smtp://postmaster@沙盒****.mailgun.org:XXXX@smtp.mailgun.org:587“流星


我在Ubuntu终端上尝试了这一点,因此应该也可以在Mac上使用。

我在使用上面所述的代码时收到了此错误消息。
错误:Meteor.userId只能在方法调用中调用。在发布函数中使用this.userId。
您可能无法在Meteor.startup中使用Meteor.userId()。假设这只是您正在测试的一些代码,我现在只需对用户id进行硬编码,例如,
Accounts.sendVerificationEmail'bcdefsahjkda'
显然将其设置为存在的用户id。这应该在meteor方法中起作用。