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

Dl/email and mailing #38

Merged
merged 2 commits into from
Aug 23, 2024
Merged
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
1 change: 1 addition & 0 deletions app/controllers/users/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def create
if resource.active_for_authentication?
set_flash_message! :notice, :signed_up
sign_up(resource_name, resource)
UserMailer.welcome_email(resource).deliver_now # Send the welcome email
respond_with resource, location: after_sign_up_path_for(resource)
else
set_flash_message! :notice, :"signed_up_but_#{resource.inactive_message}"
Expand Down
9 changes: 9 additions & 0 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class UserMailer < ApplicationMailer
default from: '[email protected]'

def welcome_email(user)
@user = user
@url = 'http://linkarooie.com/login'
mail(to: @user.email, subject: 'Welcome to Linkarooie!')
end
end
33 changes: 33 additions & 0 deletions app/views/user_mailer/welcome_email.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!-- app/views/user_mailer/welcome_email.html.erb -->
<h1 style="font-family: Arial, sans-serif; color: #333;">
Welcome to Linkarooie, <%= @user.full_name %>!
</h1>

<p style="font-family: Arial, sans-serif; color: #555; line-height: 1.5;">
Thank you for signing up with Linkarooie! You can now manage and share all your important links in one place, along with tracking their performance.
</p>

<p style="font-family: Arial, sans-serif; color: #555; line-height: 1.5;">
To get started, log in and begin customizing your profile and adding your links:
</p>

<p style="text-align: center;">
<%= link_to 'Log in to Linkarooie', @url,
style: 'background-color: #007bff; color: white; padding: 10px 20px; text-decoration: none;
border-radius: 5px; font-family: Arial, sans-serif;' %>
</p>

<p style="font-family: Arial, sans-serif; color: #555; line-height: 1.5;">
If you have any questions or need assistance, don't hesitate to reach out. We're here to help you make the most of Linkarooie.
</p>

<p style="font-family: Arial, sans-serif; color: #555; line-height: 1.5;">
Best regards,<br>
The Linkarooie Team
</p>

<hr style="border: none; border-top: 1px solid #ddd; margin: 20px 0;">

<p style="font-family: Arial, sans-serif; color: #777; text-align: center; font-size: 12px;">
You received this email because you signed up for Linkarooie. If this wasn't you, please ignore this email or contact our support team.
</p>
16 changes: 2 additions & 14 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,8 @@

config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { address: 'localhost', port: 1025 }

# Tell Active Support which deprecation messages to disallow.
config.active_support.disallowed_deprecation_warnings = []

# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load

# Highlight code that triggered database queries in logs.
config.active_record.verbose_query_logs = true

# Highlight code that enqueued background job in logs.
config.active_job.verbose_enqueue_logs = true
# Log emails to the console
config.action_mailer.logger = ActiveSupport::Logger.new(STDOUT)

# Suppress logger output for asset requests.
config.assets.quiet = true
Expand Down
15 changes: 14 additions & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
config.consider_all_requests_local = false
config.action_controller.perform_caching = true

config.active_record.sqlite3_production_warning=false
config.active_record.sqlite3_production_warning = false

# Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment
# key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files).
Expand Down Expand Up @@ -97,4 +97,17 @@
# ]
# Skip DNS rebinding protection for the default health check endpoint.
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }

# SMTP settings for Gmail
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: "smtp-relay.gmail.com",
port: 587,
domain: "linkarooie.com", # Replace with your domain
enable_starttls_auto: true,
openssl_verify_mode: 'none'
}

config.action_mailer.default_url_options = { host: "linkarooie.com" } # Replace with your domain

end
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
Loading