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

293 views Asked by At

I'm using contact_us gem and it was working well until I added another mailer. The second mailer is working well but the contact_us form works just when the email field is my default from email in another mailer! Here are the files and settings:

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 = "[email protected]"
  config.mailer_from = nil

  # Configure the e-mail address which should receive the contact form email notifications.
  config.mailer_to = "[email protected]"

  # ==> 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\" <[email protected]>"
    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

and my contact_us form is like this:

      <% @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 %>

So, the problem is that it works only when the user submits [email protected] as his mail address in the contact_us form!! Any idea and help would be appreciated ...

0

There are 0 answers