diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb index 7b195db..e2ca07e 100644 --- a/app/controllers/users/registrations_controller.rb +++ b/app/controllers/users/registrations_controller.rb @@ -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}" diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb new file mode 100644 index 0000000..ab40e46 --- /dev/null +++ b/app/mailers/user_mailer.rb @@ -0,0 +1,9 @@ +class UserMailer < ApplicationMailer + default from: 'loftwah@linkarooie.com' + + def welcome_email(user) + @user = user + @url = 'http://linkarooie.com/login' + mail(to: @user.email, subject: 'Welcome to Linkarooie!') + 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..fffce0e --- /dev/null +++ b/app/views/user_mailer/welcome_email.html.erb @@ -0,0 +1,33 @@ + +
+ 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. +
+ ++ To get started, log in and begin customizing your profile and adding your links: +
+ ++ <%= 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;' %> +
+ ++ 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. +
+ +
+ Best regards,
+ The Linkarooie Team
+
+ You received this email because you signed up for Linkarooie. If this wasn't you, please ignore this email or contact our support team. +
diff --git a/config/environments/development.rb b/config/environments/development.rb index c358286..5fdc56a 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -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 diff --git a/config/environments/production.rb b/config/environments/production.rb index 8a9f7c5..58e5b87 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -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). @@ -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 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