0

私はRuby on Railsメーラーを初めて使用しています。モデルで作成Emailerしました。mailer私のコードは次のようになります。

私のアクションメーラーEmailer.rbは次のとおりです。

class Emailer < ActionMailer::Base
  default from: 'saghir.alam@xxxxxxx.com'

def contact(recipient, subject, message, sent_at = Time.now)
      @subject = subject
      @recipients = recipient
      @from = 'saghir.alam@xxxxxxx.com'
      @sent_on = sent_at
      @body= message
      @headers = {}
   end
end

emailer_controller.rb

class EmailerController < ApplicationController
    def sendmail
      email = params["emailer"]
     recipient = email["recipient"]
     subject = email["subject"]
     message = email["message"]
      Emailer.contact(recipient, subject, message)
      return if request.xhr?
      render :text => 'Message sent successfully'
   end


      def index
      render :file => 'app\views\emailer\index.rhtml'
   end
end

index.rhtml ファイルはview/emailer次のようになります。

<h1>Send Email</h1>
<%= form_for :emailer,:url =>{ :action => :sendmail } do |f| %>
    <p><label for="email_subject">Subject</label>
        <%= f.text_field  'subject' %></p>
    <p><label for="email_recipient">Recipient</label>
        <%= f.text_field  'recipient' %></p>
    <p><label for="email_message">Message</label>
        <%= f.text_area  'message' %></p>
    <%= f.submit "Send" %>
<% end %>

ここに私の部分がありますroutes.rb

  match "/email", to: 'emailer#index'
    match "/emailer", to: 'emailer#sendmail'

私のconfig/enivronment/development.rb

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.server_settings = {
   :address => "smtp.xxxx.com",
   :port => 25,
   :domain => "xxxx.com",
   :authentication => :login,
   :user_name => "saghir.alam@xxxxxx.com",
   :password => "xxxxxxx",
}

私の問題は、送信ボタンをクリックすると、に示されているように「メッセージが送信されました」と表示されることですがemailer_controller、何も受信していません。私のコードの何が問題なのですか。ガイドしてください

4

2 に答える 2