· 7 years ago · Feb 03, 2019, 03:24 PM
1ActionMailer::Base.smtp_settings ={
2 :address => "smtp.gmail.com",
3 :port => 587,
4 :domain => "gmail.com",
5 :user_name => "my_user_name@gmail.com",
6 :password => "my_password",
7 :authentication => "Plain",
8 :enable_starttls_auto => true
9}
10
11# Don't care if the mailer can't send
12config.action_mailer.raise_delivery_errors = true
13config.action_mailer.perform_deliveries = true #default value
14config.action_mailer.delivery_method = :smtp #default value
15
16config.action_mailer.delivery_method = :smtp
17
18def create
19 @user = User.new(params[:user])
20 if @user.save
21 UserMailer.registration_confirmation(@user).deliver
22 sign_in @user
23 redirect_to @user, :flash => { :success => "Welcome to the Sample App!" }
24 else
25 @title = "Sign up"
26 render 'new'
27 end
28end
29
30default :from => "my_user_name@gmail.com"
31
32def registration_confirmation(user)
33mail(:to => user.email, :subject => "Thanks for registering")
34
35end
36end
37
38mail(:to .....).deliver!
39
40ActionMailer::Base.smtp_settings ={
41 :address => "smtp.gmail.com",
42 :port => 587,
43 :domain => "gmail.com",
44 :user_name => "my_user_name@gmail.com",
45 :password => "my_password",
46 :authentication => :plain,
47 :enable_starttls_auto => true
48}