Description:
sends mails by mail gem
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r331:4917c2675f37 - - 4 files changed: 66 inserted, 47 deleted

@@ -34,13 +34,13
34 34 # gem 'capistrano'
35 35
36 36 # To use debugger
37 37 # gem 'debugger'
38 38
39 39 gem "haml"
40 - gem "tmail"
40 + gem "mail"
41 41 gem "rdiscount"
42 42 gem "test-unit"
43 43 gem 'will_paginate', '~> 3.0.0'
44 44 gem 'dynamic_form'
45 45 gem 'in_place_editing'
46 46 gem 'verification', :git => 'git://github.com/sikachu/verification.git'
@@ -114,13 +114,12
114 114 hike (~> 1.2)
115 115 rack (~> 1.0)
116 116 tilt (~> 1.1, != 1.3.0)
117 117 test-unit (2.5.2)
118 118 thor (0.16.0)
119 119 tilt (1.3.3)
120 - tmail (1.2.7.1)
121 120 treetop (1.4.10)
122 121 polyglot
123 122 polyglot (>= 0.3.1)
124 123 tzinfo (0.3.33)
125 124 uglifier (1.3.0)
126 125 execjs (>= 0.3.0)
@@ -132,17 +131,17
132 131
133 132 DEPENDENCIES
134 133 coffee-rails (~> 3.2.1)
135 134 dynamic_form
136 135 haml
137 136 in_place_editing
137 + mail
138 138 mysql2
139 139 prototype-rails
140 140 rails (= 3.2.8)
141 141 rdiscount
142 142 rspec-rails (~> 2.0)
143 143 sass-rails (~> 3.2.3)
144 144 test-unit
145 - tmail
146 145 uglifier (>= 1.0.3)
147 146 verification!
148 147 will_paginate (~> 3.0.0)
@@ -1,10 +1,8
1 1 class UserAdminController < ApplicationController
2 2
3 - #include MailHelperMethods
4 -
5 3 before_filter :admin_authorization
6 4
7 5 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
8 6 verify :method => :post, :only => [ :destroy,
9 7 :create, :create_from_list,
10 8 :update,
@@ -313,30 +311,37
313 311 lines = params[:login_list]
314 312 if !lines or lines.blank?
315 313 flash[:notice] = 'You entered an empty list.'
316 314 redirect_to :action => 'mass_mailing' and return
317 315 end
318 316
319 - subject = params[:subject]
320 - if !subject or subject.blank?
317 + mail_subject = params[:subject]
318 + if !mail_subject or mail_subject.blank?
321 319 flash[:notice] = 'You entered an empty mail subject.'
322 320 redirect_to :action => 'mass_mailing' and return
323 321 end
322 +
323 + mail_body = params[:email_body]
324 + if !mail_body or mail_body.blank?
325 + flash[:notice] = 'You entered an empty mail body.'
326 + redirect_to :action => 'mass_mailing' and return
327 + end
324 328
325 - body = params[:email_body]
326 - if !body or body.blank?
327 - flash[:notice] = 'You entered an empty mail body.'
328 - redirect_to :action => 'mass_mailing' and return
329 - end
329 + admin_email = GraderConfiguration['system.admin_email']
330 330
331 331 note = []
332 332 users = []
333 333 lines.split("\n").each do |line|
334 334 user = User.find_by_login(line.chomp)
335 335 if user
336 - send_mail(user.email, subject, body)
336 + Mail.deliver do
337 + from admin_email
338 + to user.email
339 + subject mail_subject
340 + body mail_body
341 + end
337 342 note << user.login
338 343 end
339 344 end
340 345
341 346 flash[:notice] = 'User(s) ' + note.join(', ') +
342 347 ' were successfully modified. '
@@ -423,23 +428,30
423 428 end
424 429 end
425 430
426 431 def send_contest_update_notification_email(user, contest)
427 432 contest_title_name = GraderConfiguration['contest.name']
428 433 contest_name = contest.name
429 - subject = t('contest.notification.email_subject', {
430 - :contest_title_name => contest_title_name,
431 - :contest_name => contest_name })
432 - body = t('contest.notification.email_body', {
433 - :full_name => user.full_name,
434 - :contest_title_name => contest_title_name,
435 - :contest_name => contest.name,
436 - })
434 + mail_subject = t('contest.notification.email_subject', {
435 + :contest_title_name => contest_title_name,
436 + :contest_name => contest_name })
437 + mail_body = t('contest.notification.email_body', {
438 + :full_name => user.full_name,
439 + :contest_title_name => contest_title_name,
440 + :contest_name => contest.name,
441 + })
437 442
438 - logger.info body
439 - send_mail(user.email, subject, body)
443 + admin_email = GraderConfiguration['system.admin_email']
444 +
445 + logger.info mail_body
446 + Mail.deliver do
447 + from admin_email
448 + to user.email
449 + subject mail_subject
450 + body mail_body
451 + end
440 452 end
441 453
442 454 def find_contest_and_user_from_contest_id(id)
443 455 if id!='none'
444 456 @contest = Contest.find(id)
445 457 else
@@ -1,13 +1,10
1 - require 'tmail'
2 1 require 'net/smtp'
3 2
4 3 class UsersController < ApplicationController
5 4
6 - #include MailHelperMethods
7 -
8 5 before_filter :authenticate, :except => [:new,
9 6 :register,
10 7 :confirm,
11 8 :forget,
12 9 :retrieve_password]
13 10
@@ -121,38 +118,49
121 118 contest_name = GraderConfiguration['contest.name']
122 119 admin_email = GraderConfiguration['system.admin_email']
123 120 activation_url = url_for(:action => 'confirm',
124 121 :login => user.login,
125 122 :activation => user.activation_key)
126 123 home_url = url_for(:controller => 'main', :action => 'index')
127 - subject = "[#{contest_name}] Confirmation"
128 - body = t('registration.email_body', {
129 - :full_name => user.full_name,
130 - :contest_name => contest_name,
131 - :login => user.login,
132 - :password => user.password,
133 - :activation_url => activation_url,
134 - :admin_email => admin_email
135 - })
124 + mail_subject = "[#{contest_name}] Confirmation"
125 + mail_body = t('registration.email_body', {
126 + :full_name => user.full_name,
127 + :contest_name => contest_name,
128 + :login => user.login,
129 + :password => user.password,
130 + :activation_url => activation_url,
131 + :admin_email => admin_email
132 + })
136 133
137 - logger.info body
134 + logger.info mail_body
138 135
139 - send_mail(user.email, subject, body)
136 + Mail.deliver do
137 + from admin_email
138 + to user.email
139 + subject mail_subject
140 + body mail_body
141 + end
140 142 end
141 143
142 144 def send_new_password_email(user)
143 145 contest_name = GraderConfiguration['contest.name']
144 146 admin_email = GraderConfiguration['system.admin_email']
145 - subject = "[#{contest_name}] Password recovery"
146 - body = t('registration.password_retrieval.email_body', {
147 - :full_name => user.full_name,
148 - :contest_name => contest_name,
149 - :login => user.login,
150 - :password => user.password,
151 - :admin_email => admin_email
152 - })
147 + mail_subject = "[#{contest_name}] Password recovery"
148 + mail_body = t('registration.password_retrieval.email_body', {
149 + :full_name => user.full_name,
150 + :contest_name => contest_name,
151 + :login => user.login,
152 + :password => user.password,
153 + :admin_email => admin_email
154 + })
153 155
154 - logger.info body
155 - send_mail(user.email, subject, body)
156 + logger.info mail_body
157 +
158 + Mail.deliver do
159 + from admin_email
160 + to user.email
161 + subject mail_subject
162 + body mail_body
163 + end
156 164 end
157 165
158 166 end
You need to be logged in to leave comments. Login now