I'm new in Rails. I'm trying to make a email notification about new messages of contact form using ActionMailer. I followed different tutorials, tried to apply different advices, but it didnt help.
My setup_mail.rb
file is:
config.action_mailer.delivery_method = :sendmail
ActionMailer::Base.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'gmail.com',
user_name: 'my_user_name',
password: 'my_password',
authentication: 'plain',
enable_starttls_auto: true
}
I tried tp add this code to the development.rb
file, my development.rb
also has next code:
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
My contact_forms_controllers.rb
has next code:
def create
@contact_form = ContactForm.new contact_form_params
@contact_form.save
redirect_to root_path
AdminMailer.notification(@contact_form).deliver
end
My admin_mailer.rb file is:
class AdminMailer < ApplicationMailer
default from: "my_address@gmail.com"
def notification(contact_form)
mail(to: "my_address@gmail.com", subject: 'New message on your web-site')
end
end
Everywhere my_address@gmail.com is my actual mail and my_password is my actual password.
I can create a message by help contact form without any errors. Has anybody idea, where can be a problem?