电子邮件没有使用sidekiq在rails 4中发送

时间:2015-12-22 12:42:58

标签: ruby ruby-on-rails-4

我正在尝试使用sidekiq在rails 4中发送电子邮件。 在此,值不会保存在数据库中,而是仅采用表单值并发送电子邮件。 我已经完成了这个链接https://www.codefellows.org/blog/how-to-set-up-a-rails-4-2-mailer-with-sidekiq

但问题是电子邮件没有收到。

visitor_controller.rb

class VisitorsController < ApplicationController
    def index

    end

    def contact
        h = JSON.generate({ 'name' => params[:name],
                            'email' => params[:email],
                            'message' => params[:message] })

       PostmanWorker.perform_async(h, 5)

        # if instead of sidekiq I was just sending email from rails
         #VisitorMailer.contact_email(@name, @email, @message).deliver

        redirect_to :root
    end
end

visitor_mailer.rb

class VisitorMailer < ApplicationMailer
    def contact_email(name, email, message)
    @name = name
    @email = email
    @message = message
    mail(from: @email,
        to: 'javier@badaboom.com',
         subject: 'New Visitor\'s Email')
  end
end

contact_email.html.erb

<html>
   <head>
     <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
   </head>
   <body>
     <h1><%= @name %> (<%= @email %>)</h1>
     <p>
       <%= @message %>
     </p>
   </body>
 </html>

index.html.erb

<h1>Email</h1> 

<p>
    <%= label_tag(:name, "My name is:") %>
  <%= text_field_tag(:name) %>
</p>

<p>
    <%= label_tag(:email, "My email address is:") %>
  <%= text_field_tag(:email) %>
</p>

<p>
    <%= label_tag(:message, "My Message is:") %>
    <%= text_area_tag(:message) %>
</p>


<p>
    <%= submit_tag("Send Email") %>
</p>

我想知道为什么电子邮件没有发送... 在此先感谢!!!!

0 个答案:

没有答案