OSDN Git Service

[#169] – Move email 'from' & 'host' settings to config file
authorValery Sizov <vsv2711@gmail.com>
Tue, 22 Nov 2011 21:36:14 +0000 (23:36 +0200)
committerValery Sizov <vsv2711@gmail.com>
Tue, 22 Nov 2011 21:36:14 +0000 (23:36 +0200)
app/mailers/notify.rb
config/email.yml [new file with mode: 0644]
config/initializers/load_config.rb

index 56e4de9..26a0640 100644 (file)
@@ -5,7 +5,7 @@ class Notify < ActionMailer::Base
   def new_user_email(user, password)
     @user = user
     @password = password
-    mail(:to => @user.email, :subject => "gitlab | Account was created for you")
+    mail(:to => @user.email, :subject => "gitlab | Account was created for you", :from => EMAIL_OPTS["from"])
   end
 
   def new_issue_email(issue)
@@ -13,14 +13,14 @@ class Notify < ActionMailer::Base
     @project = issue.project
     @issue = issue
 
-    mail(:to => @user.email, :subject => "gitlab | New Issue was created")
+    mail(:to => @user.email, :subject => "gitlab | New Issue was created", :from => EMAIL_OPTS["from"])
   end
 
   def note_wall_email(user, note)
     @user = user
     @note = note
     @project = note.project
-    mail(:to => @user.email, :subject => "gitlab | #{@note.project.name} ")
+    mail(:to => @user.email, :subject => "gitlab | #{@note.project.name} ", :from => EMAIL_OPTS["from"])
   end
 
   def note_commit_email(user, note)
@@ -28,7 +28,7 @@ class Notify < ActionMailer::Base
     @note = note
     @project = note.project
     @commit = @project.repo.commits(note.noteable_id).first
-    mail(:to => @user.email, :subject => "gitlab | #{@note.project.name} ")
+    mail(:to => @user.email, :subject => "gitlab | #{@note.project.name} ", :from => EMAIL_OPTS["from"])
   end
 
   def note_issue_email(user, note)
@@ -36,6 +36,6 @@ class Notify < ActionMailer::Base
     @note = note
     @project = note.project
     @issue = note.noteable
-    mail(:to => @user.email, :subject => "gitlab | #{@note.project.name} ")
+    mail(:to => @user.email, :subject => "gitlab | #{@note.project.name} ", :from => EMAIL_OPTS["from"])
   end
 end
diff --git a/config/email.yml b/config/email.yml
new file mode 100644 (file)
index 0000000..a763e10
--- /dev/null
@@ -0,0 +1 @@
+from: notify@gitlabhq.com
index 6c7289e..60f8515 100644 (file)
@@ -1 +1,2 @@
 GITOSIS = YAML.load_file("#{Rails.root}/config/gitosis.yml")
+EMAIL_OPTS = YAML.load_file("#{Rails.root}/config/email.yml")