Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add user mailer #90

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class UserMailer < ApplicationMailer
def welcome_email(user)
@user = user
mail(to: @user.email, subject: 'Welcome to Anity Jobs')
end
end
6 changes: 6 additions & 0 deletions app/views/user_mailer/welcome_email.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<h1>Welcome to Anity Jobs, <%= @user.email %></h1>
<p>
You have successfully signed up to example.com,
your username is: <%= @user.email %>.<br>
</p>
<p>Thanks for joining and have a great day!</p>
5 changes: 5 additions & 0 deletions app/views/user_mailer/welcome_email.text.erb
Original file line number Diff line number Diff line change
@@ -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!
16 changes: 15 additions & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: '[email protected]'}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the from email address?


config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'example.com',
user_name: '<username>',
password: '<password>',
Comment on lines +51 to +53
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to provide the credentials here for the SMTP to be functional

authentication: 'plain',
enable_starttls_auto: true
}

config.action_mailer.perform_caching = false

Expand Down
4 changes: 4 additions & 0 deletions spec/mailers/previews/user_mailer_preview.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Preview all emails at http://localhost:3000/rails/mailers/user_mailer
class UserMailerPreview < ActionMailer::Preview

end
5 changes: 5 additions & 0 deletions spec/mailers/user_mailer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require "rails_helper"

RSpec.describe UserMailer, type: :mailer do
pending "add some examples to (or delete) #{__FILE__}"
end