如何使用gem griddler在rails app中接收电子邮件?
我点这个链接:http://sendgrid.com/blog/receiving-email-in-your-rails-app-with-griddler/
我的index.html.erb posts_controller:
<% if @posts.count > 0 %>
<% @posts.each do |post| %>
<blockquote>
<p><%= post.body %></p>
<small><%= post.email %></small>
</blockquote>
<% end %>
<% else %>
<p><em>Oops, doesn't look like there are any posts yet.</em></p>
<% end %>
我的config / initializer / griddler.rb:
Griddler.configure do |config|
config.processor_class = EmailProcessor # MyEmailProcessor
config.to = :hash # :full, :email, :token
config.from = :email # :full, :token, :hash
# :raw => 'AppName <s13.6b2d13dc6a1d33db7644@mail.myapp.com>'
# :email => 's13.6b2d13dc6a1d33db7644@mail.myapp.com'
# :token => 's13.6b2d13dc6a1d33db7644'
# :hash => { raw: [...], email: [...], token: [...], host: [...],
# name: [...] }
config.reply_delimiter = '-- REPLY ABOVE THIS LINE --'
config.email_service = :sendgrid # :cloudmailin, :postmark, :mandrill, :mailgun
end
我的lib / email_processor.rb:
class EmailProcessor
def self.process(email)
# all of your application-specific code here - creating models,
# processing reports, etc
Post.create!({ body: email.body, email: email.from })
end
end
但是在索引帖子视图中没有得到任何回调,为什么?
答案 0 :(得分:1)
您必须在sendgrid http://sendgrid.com/developer/reply提供您网站的重定向网址。
如果您想提供localhost网址,请使用https://ngrok.com/