Showing posts with the label email

Send email in rails

Sending Emails Using ActionMailer and Gmail Create new rails application rails new new_app_name rails g scaffold user name:string email:string contact:string rake db:migrate rails g mailer example_mailer In  app/mailers/user_mailer.rb class UserMailer < ActionMailer::Base    def sample_email(user)     @user = user     mail(to:, subject: 'Sample Email, text:"simple text"')   end end app/views/user_mailer/sample_email.html.erb <!DOCTYPE html> <html>   <head>     <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />   </head>   <body>     <h1>Hi <%= %></h1>     <p>       Sample mail sent using smtp.     </p>   </body> </html> /config/application.yml gmail_username: '' gmail_password: 'Gmail password' /config/environments/production.rb config.action_mailer.deliver