电子邮件打开通知 - 在轨道上的ruby [英] Email open notification - ruby on rails

查看:91
本文介绍了电子邮件打开通知 - 在轨道上的ruby的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我将向注册用户发送100封电子邮件,我想知道用户是否打开电子邮件

If I will send 100 email to the registered user and I want to know if users open email or not

如何使用Ruby on Rails? / p>

How can I do this using Ruby on Rails?

推荐答案

这样做的唯一方法是使用html电子邮件与跟踪器图像。您需要在代码中包含用户特定的图像。

The only way to do this, is to use html email with a tracker image. You need to include a user specific image into the code.

class TrackingController < ApplicationController
  def image
    # do something with params[:id]
    send_file "/path/to/an/image"
  end
end

添加以下路线:

# Rails 2
map.tracking_image "tracking_image/:id.gif", :controller => 'tracking', :action => image

# Rails 3
match 'products/:id', :to => 'tracking#image', :as => "tracking_image"

# Rails 4 (match without verb is deprecated)
get 'producsts/:id' => 'tracking#image', as: 'tracking_image'
# or
match 'producsts/:id' => 'tracking#image', as: 'tracking_image', via: :get

在您的电子邮件模板中像这样:

in your email template something like this:

<%= image_tag tracking_image_url(@user.id) %>

但请注意,这并不能保证用户读取电子邮件并加载图像电子邮件客户端不加载图像,直到用户想要。如果他不这样做,你就不能做任何事情。另外如果用户使用文本邮件,这两者也不会工作。

But be aware, that this it's not guaranteed that the user reads the email and loads the image, some email clients don't load images, until the user wants to. And If he doesn't you can't do anything about this. Also if the user uses text mail only this won't work neither.

这篇关于电子邮件打开通知 - 在轨道上的ruby的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆