def mass_mail
@recipients = Person.mailable
return true unless request.post?
if params[:title].nil? or params[:title].empty? or
params[:body].nil? or params[:body].empty?
flash[:error] << _('You must specify both email title and body')
return false
end
@recipients.each do |rcpt|
begin
Notification.deliver_admin_mail(@user, rcpt,
params[:title], params[:body])
rescue Notification::InvalidEmail
flash[:warning] << _('User %s (ID: %s) is registered with an ' +
'invalid email address (%s). Skipping...') %
[rcpt.name, rcpt.id, rcpt.email]
end
end
flash[:notice] << _('The %d requested mails have been sent.') %
@recipients.size
redirect_to :action => 'list'
end