简体   繁体   English

启动前邮件程序不起作用

[英]Prelaunchr mailer not working

I am running Harry's prelaunchr ( https://github.com/harrystech/prelaunchr ) on Heroku and the welcome email that is supposed to send out when a new user signs up on the site is not sending out. 我正在Heroku上运行Harry的prelaunchr( https://github.com/harrystech/prelaunchr ),而当新用户注册该站点时,应该发送的欢迎电子邮件并未发送出去。 The rails app is using Delayed::Job and when I run Rails应用程序正在使用Delayed :: Job并在我运行时

heroku rake jobs:work

I get the following output: 我得到以下输出:

 Rendered user_mailer/signup_email.html.erb (1.2ms)
[Worker(host:46d2c895-5e66-464b-8594-510461de915c pid:3)] Class#signup_email failed with ActionView::Template::Error: undefined method `encoding' for {:host=>"windreturns.com"}:Hash - 9 failed attempts

^Note: host=>"windreturns.com" is my domain, but it is not where the site is currently located (it's a genericname.herokuapp.com domain) ^注意:host =>“ windreturns.com”是我的域,但不是该站点当前所在的位置(这是一个genericname.herokuapp.com域)

Any idea why the jobs are failing? 知道为什么工作失败了吗? How do I get the emails to send? 如何获得要发送的电子邮件?

I'm not sure why, but it seems like the file app/views/user_mailer/signup_email.html.erb has several issues, dating back to the initial commit that had a syntax error in it. 我不确定为什么,但是文件app/views/user_mailer/signup_email.html.erb有几个问题,可以追溯到最初的提交中出现语法错误。 The current version is using asset links like this: 当前版本使用的资产链接如下:

<%= Rails.application.config.action_mailer.default_url_options %>/assets/logo.jpg

The first problem with this is that default_url_options is not a string, it's a hash. 第一个问题是default_url_options不是字符串,而是哈希值。 The second problem is that the email assets are in /assets/email . 第二个问题是电子邮件资产位于/assets/email I got the email working by changing the above to: 通过将以上内容更改为:

<%= Rails.application.config.action_mailer.default_url_options[:host] %>/assets/email/logo.jpg

You have to do this in nine places, then it should work. 您必须在9个地方执行此操作,然后它应该起作用。

Also set something like DEFAULT_MAILER_HOST="http://localhost:5000" in your .env file. 还要在.env文件中设置DEFAULT_MAILER_HOST="http://localhost:5000".env

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM