为什么我的电子邮件确认显示在Google Chrome上,而不是Internet Explorer上

时间:2015-03-05 17:11:49

标签: ruby-on-rails ruby google-chrome gem internet-explorer-11

在我的Ruby on Rails应用程序中,我使用字母开启器gem来显示发送给用户的电子邮件消息,以确认他们已在系统上注册。但是HTML不适用于IE,但它确实适用于谷歌Chrome,任何想法?

没有错误消息,它会显示电子邮件发送给谁以及来自谁,但没有内容,即它不显示welcome_email.html.erb中的内容

应用程序/邮寄者/ application_mailer.rb:

class ApplicationMailer < ActionMailer::Base
  default sender: "ben@thorcinemas.com"
  layout 'mailer'
end

应用程序/邮寄者/ user_mailer.rb:

class UserMailer < ApplicationMailer
  default from: 'notifications@example.com'

  def welcome_email(user)
    @user = user
    @url  = 'http://localhost:3000/users/login'
    mail(to: @user.email, subject: 'Welcome to My Awesome Site')
  end
end

应用程序/视图/ user_mailer文件/ welcome_email.html.erb:

<!DOCTYPE html>
<html>
  <head>
    <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
  </head>
  <body>
    <h1>Welcome to example.com, <%= @user.first_name %></h1>
    <p>
      You have successfully signed up to example.com,
      your username is: <%= @user.first_name %><%= @user.last_name %>.<br>
    </p>
    <p>
      To login to the site, just follow this link: <%= @url %>.
    </p>
    <p>Thanks for joining and have a great day!</p>
  </body>
</html>

应用程序/视图/ user_mailer文件/ welcome_email.txt.erb:

Welcome to example.com, <%= @user.first_name %>
===============================================

You have successfully signed up to example.com,
your username is: <%= @user.first_name %><%= @user.last_name %>.

To login to the site, just follow this link: <%= @url %>.

Thanks for joining and have a great day!

应用程序/控制器/ users_controller.rb:

  def create
    @user = User.new(user_params)
    if @user.save
      # login is achieved by saving a user's 'id' in a session variable, 
      # accessible to all pages
       session[:user_id] = @user.id
       UserMailer.welcome_email(@user).deliver_later
       redirect_to films_path
    else
       render action: "new"
    end
  end

0 个答案:

没有答案