0

我在尝试获取联系页面以正确发送电子邮件时遇到问题。该页面在 Heroku 上托管的 Rails 上运行 ruby​​,并且根据 papertrail 发送它没有错误。日志如下:

    Jun 12 15:14:37 dry-woodland-1410 app/web.1:  Processing by ontactController#create as HTML Jun 12 15:14:37 dry-woodland-1410 app/web.1:    Parameters: {"utf8"=>"✓",authenticity_token"=>"IRu+hjuGuo0Dw5hM0jOOAxFqyT6CXoubk5TocJqw7w4=", "message"=>{"name"=>"example", "email"=>"example@example.com", "subject"=>"subject", "body"=>"body"}, "commit"=>"Send"} Jun 12 15:14:38 dry-woodland-1410 app/web.1:    Rendered contact_mailer/new_message.text.erb (0.1ms) Jun 12 15:14:38 dry-woodland-1410 app/web.1:  Sent mail to contact@akimono.com (127ms) Jun 12 15:14:38 dry-woodland-1410 app/web.1:  Redirected to http://dry-woodland-1410.herokuapp.com/products 

这是接触控制器的代码:

    class ContactController < ApplicationController
def new
    @message = Message.new
    @cart = current_cart
end
def create
    @message = Message.new(params[:message])
    @cart = current_cart
    if @message.valid?
        ContactMailer.new_message(@message).deliver
        redirect_to(products_path, :notice => "Your message was successfully sent. If you do not hear back in one business day please resend.")
    else
        flash.now.alert = "Please fill all fields."
        render :new
    end
    end   
    end

这是联系人新视图的代码:

    <%= form_for @message, :url => contact_path do |form| %>
    <fieldset class="fields">
<div class="field">
    <%= form.label :name %>
    <%= form.text_field :name %>
</div>

<div class="field">
    <%= form.label :email %>
    <%= form.text_field :email %>
</div>
<div class="field">
    <%= form.label :subject %>
    <%= form.text_field :subject %>
</div>
<div class="field">
    <%= form.label :body%>
    <%= form.text_field :body %>
</div>
    </fieldset>
    <fieldset class="actions">
<%= form.submit "Send" %>
</fieldset>
<% end %>

我到处查看,无法弄清楚为什么实际上没有发送消息并且没有抛出错误消息,即使一切似乎都已到位。

联系邮件代码:

    Name: <%= @message.name %>

    Email: <%= @message.email %>

    Subject: <%= @message.subject %>

    Body: <%= @message.body %>
4

0 回答 0