Skip to content

Commit

Permalink
Mailsetting now writes a file to confirm the status
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Moravec committed Dec 20, 2012
1 parent fbf6080 commit 9370617
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions plugins/mailsetting/app/models/mailsetting.rb
Expand Up @@ -43,7 +43,7 @@ class Mailsetting < BaseModel::Base
validates :password_confirmation, :presence=>true
validates :transport_layer_security, :presence=>true

TEST_MAIL_FILE = File.join(YaST::Paths::VAR,"mail","test_sent")
TEST_MAIL_FILE = File.join(YaST::Paths::VAR,"mailsetting","test_sent")
CACHE_ID = "webyast_mailsetting"

# read the settings from system
Expand Down Expand Up @@ -87,15 +87,17 @@ def self.send_test_mail(to)
to.tr!("~'\"<>","")
`/bin/echo "#{message}" | /bin/mail -s "WebYaST Test Mail" '#{to}' -r root`

unless File.directory? File.join(YaST::Paths::VAR,"mail")
Rails.logger.debug "directory does not exists...."
mail_directory = File.join(YaST::Paths::VAR,"mailsetting")
unless File.directory? mail_directory
Rails.logger.debug "Directory #{mail_directory} does not exists"
return
end
begin
f = File.new(TEST_MAIL_FILE, 'w')
f.puts "#{to}"
rescue
Rails.logger.error "writing #{TEST_MAIL_FILE} file failed - wrong permissions?"
File.open TEST_MAIL_FILE, 'w' do |file|
file.puts to.to_s
end
rescue => error
Rails.logger.error e
end
end
end
Expand Down

0 comments on commit 9370617

Please sign in to comment.