Rails,Contact_us:Net :: SMTPFatalError(550-Your FROM address

时间:2016-12-14 16:40:36

标签: ruby-on-rails ruby-on-rails-4 mailer contactus

我正在使用contact_us gem并且在我添加另一封邮件之前它运行良好。第二个邮件程序运行良好,但contact_us表单只有当电子邮件字段是我在另一个邮件程序中的电子邮件默认值时才有效!以下是文件和设置:

contact_us.rb

# Use this hook to configure contact mailer.
ContactUs.setup do |config|

  # ==> Mailer Configuration

  # Configure the e-mail address which email notifications should be sent from.  If emails must be sent from a verified email address you may set it here.
  # Example:
  # config.mailer_from = "contact@please-change-me.com"
  config.mailer_from = nil

  # Configure the e-mail address which should receive the contact form email notifications.
  config.mailer_to = "hi@mysite.com"

  # ==> Form Configuration

  # Configure the form to ask for the users name.
  config.require_name = false

  # Configure the form to ask for a subject.
  config.require_subject = false

  # Configure the form gem to use.
  # Example:
  # config.form_gem = 'formtastic'
  config.form_gem = nil

  # Configure the redirect URL after a successful submission
  config.success_redirect = '/'

end

application_mailer.rb

class ApplicationMailer < ActionMailer::Base

end

my_mailer.rb

class MyMailer < ApplicationMailer
    default from: "\"mysite\" <hi@mysite.com>"
    layout 'mailer'
    #The email that should be sent to the Passenger after his successful payment
    def payment_confirmation(user, trip, seats, code)
        ...
        mail(to: @user.email, subject: "...")
    end

end

我的contact_us表格是这样的:

      <% @contact = ContactUs::Contact.new %>
     <%= form_for @contact, :url => contacts_path, :id => "contact-form", :html => {:class => 'formtastic'} do |f| %>
        <div class="input-group name-email">
          <div class="input-field">

            <%= f.text_field :name, :id => "name", :placeholder => "نام", :class => "form-control" %>
          </div>
          <div class="input-field">

              <%= f.text_field :email, :id => "email", :placeholder => "ایمیل*", :class => "form-control"  %>
              <% if f.object.errors[:email].present? %>
                <p class='inline-error'><%= f.object.errors[:email].join(' and ') %></p>
              <% end %>
          </div>
        </div>
        <div class="input-group">

          <%= f.text_area :message, :id => "message", :placeholder => "پیغام*", :class => "form-control" %>
        </div>
        <div class="input-group">

          <%= f.submit "ارسال پیغام", :id => "form-submit", :class => "pull-left" %>
        </div>

      <% end %>

所以,问题是只有当用户以contact_us形式提交hi@mysite.com作为他的邮件地址时才会起作用!! 任何想法和帮助将不胜感激......

0 个答案:

没有答案