diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb new file mode 100644 index 0000000..17ed9d1 --- /dev/null +++ b/app/mailers/user_mailer.rb @@ -0,0 +1,6 @@ +class UserMailer < ApplicationMailer + def welcome_email(user) + @user = user + mail(to: @user.email, subject: 'Welcome to Anity Jobs') + end +end diff --git a/app/views/user_mailer/welcome_email.html.erb b/app/views/user_mailer/welcome_email.html.erb new file mode 100644 index 0000000..9f962a3 --- /dev/null +++ b/app/views/user_mailer/welcome_email.html.erb @@ -0,0 +1,6 @@ +

Welcome to Anity Jobs, <%= @user.email %>

+

+ You have successfully signed up to example.com, + your username is: <%= @user.email %>.
+

+

Thanks for joining and have a great day!

\ No newline at end of file diff --git a/app/views/user_mailer/welcome_email.text.erb b/app/views/user_mailer/welcome_email.text.erb new file mode 100644 index 0000000..49073ea --- /dev/null +++ b/app/views/user_mailer/welcome_email.text.erb @@ -0,0 +1,5 @@ +Welcome to Anity jobs, <%= @user.email %> +=============================================== +You have successfully signed up to Anity jobs, +your username is: <%= @user.email %>. +Thanks for joining and have a great day! \ No newline at end of file diff --git a/config/environments/development.rb b/config/environments/development.rb index f284f62..fb70c86 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -39,7 +39,21 @@ config.active_storage.service = :local # Don't care if the mailer can't send. - config.action_mailer.raise_delivery_errors = false + + config.action_mailer.delivery_method = :smtp + config.action_mailer.perform_deliveries = true + config.action_mailer.raise_delivery_errors = true + config.action_mailer.default_options = {from: 'no-reply@example.com'} + + config.action_mailer.smtp_settings = { + address: 'smtp.gmail.com', + port: 587, + domain: 'example.com', + user_name: '', + password: '', + authentication: 'plain', + enable_starttls_auto: true + } config.action_mailer.perform_caching = false diff --git a/spec/mailers/previews/user_mailer_preview.rb b/spec/mailers/previews/user_mailer_preview.rb new file mode 100644 index 0000000..957e12b --- /dev/null +++ b/spec/mailers/previews/user_mailer_preview.rb @@ -0,0 +1,4 @@ +# Preview all emails at http://localhost:3000/rails/mailers/user_mailer +class UserMailerPreview < ActionMailer::Preview + +end diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb new file mode 100644 index 0000000..4a78b85 --- /dev/null +++ b/spec/mailers/user_mailer_spec.rb @@ -0,0 +1,5 @@ +require "rails_helper" + +RSpec.describe UserMailer, type: :mailer do + pending "add some examples to (or delete) #{__FILE__}" +end