create sender mailer

parent 4d40a363
Pipeline #951 canceled with stages
in 0 seconds
......@@ -21,3 +21,4 @@
.text-confirm {
font-size: 26px;
}
class UsersController < ApplicationController
def new
end
def register_begin
@email = User.new(params[:email])
@email = User.new
end
def create
@email = User.new(params[:email])
@email = User.new(email: params[:user][:email])
if @email.save
UserMailer.with(email: @email).welcome_email.deliver_later
binding.pry
UserMailer.register_email(params[:user][:email]).deliver_later
redirect_to mail_register_path
else
redirect_to register_begin_path
......
class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
default from: 'phuocht@zigexn.vn'
layout 'mailer'
end
class UserMailerPreview < ActionMailer::Preview
def welcome_email
UserMailer.with(email: User.first).welcome_email
end
end
class UserMailer < ActionMailer::Base
default from: 'phuocht@gmail.com'
def welcome_email
@email = params[:email]
def register_email(email)
@email = email
mail(to: @email, subject: 'Welcome to My Awesome Site')
end
end
===============================================
You have successfully signed up to gmail.com,
Thanks for joining and have a great day!
......@@ -3,10 +3,13 @@
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
</head>
<body>
<h1>Welcome to example.com, <%= @user.name %></h1>
<h1>Welcome to example.com, <%= @email %></h1>
<p>
You have successfully signed up to example.com,
your username is: sadsad.<br>
your username is: <%= @email %>.<br>
</p>
<p>
To login to the site, just follow this link:....
</p>
<p>Thanks for joining and have a great day!</p>
</body>
......
=================================================
Welcome to example.com, <%= @email %>
HELLO
......@@ -3,12 +3,14 @@
<div class="text-center label">
<strong>Register</strong>
</div>
<div class="row">
<div class="form-register">
<%= form_for(@email) do |f| %>
<div class="text-center email-input">
<strong>Email</strong>
<%= f.text_field :email, class: 'col-6'%>
<%= f.text_field :email %>
</div>
<div class="text-center confirm-email-btn">
<%= f.submit 'Confirm your email', class: 'btn btn-outline-danger confirm' %>
<%= f.submit 'Confirm your email', class: 'btn btn-outline-danger confirm font-weight-bold' %>
</div>
<% end %>
</div>
......
......@@ -10,7 +10,6 @@ module Venjob
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2
# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded after loading
......
......@@ -27,24 +27,25 @@ Rails.application.configure do
config.cache_store = :null_store
end
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = { :host => "localhost:3000" }
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => ENV['GMAIL_USERNAME'],
:password => ENV['GMAIL_PASSWORD'],
:authentication => "plain",
:enable_starttls_auto => true
}
# Store uploaded files on the local file system (see config/storage.yml for options)
config.active_storage.service = :local
# Don't care if the mailer can't send.
config.active_job.queue_adapter = :async
config.action_mailer.default_url_options = { host: "localhost:3000" }
# config.action_mailer.default_options = { from: 'support@venjob.com' }
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: "smtp.zigexn.vn",
port: 587,
domain: "zigexn.vn",
user_name: ENV['GMAIL_USERNAME'],
password: ENV['GMAIL_PASSWORD'],
authentication: "plain",
enable_starttls_auto: true
}
config.action_mailer.perform_caching = false
......
# Rename this file to local_env.yml
# Add account settings and API keys here.
# This file should be listed in .gitignore to keep your settings secret!
# Each entry gets set as a local environment variable.
# This file overrides ENV variables in the Unix shell.
# For example, setting:
# GMAIL_USERNAME: 'Your_Gmail_Username'
# makes 'Your_Gmail_Username' available as ENV["GMAIL_USERNAME"]
GMAIL_USERNAME: 'phuocht@zigexn.vn'
GMAIL_PASSWORD: 'Thienphuoc123'
# PASSWORD_TPM: 'vjkjlbgoxqxvnbac'
......@@ -28,8 +28,6 @@
#
# To learn more, please read the Rails Internationalization guide
# available at http://guides.rubyonrails.org/i18n.html.
GMAIL_USERNAME: 'phuocht@zigexn.vn'
GMAIL_PASSWORD: 'Thienphuoc0123'
en:
hello: "Hello world"
......@@ -2,13 +2,14 @@ Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
resources :jobs
get 'detail/:id', action: :show, controller: 'jobs' , as: :job_detail
match '/register/1', to: 'users#register_begin', via: 'get', as: :register_begin
match '/register/2', to: 'users#mail_register', via: 'get', as: :mail_register
get '/register/1', to: 'users#new', as: :register_begin
get '/register/2', to: 'users#mail_register', as: :mail_register
get 'jobs/city/:converted_name', to: 'jobs#city_jobs', as: :city_jobs
get 'jobs/industry/:converted_name', to: 'jobs#industry_jobs', as: :industry_jobs
get 'jobs/company/:converted_name', to: 'jobs#company_jobs', as: :company_jobs
resources :user_mailer
resources :users
resources :top_pages
resources :industries
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment