Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
b4be7aed
Commit
b4be7aed
authored
Feb 15, 2015
by
Jakub Jirutka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow to configure smtp and sendmail in gitlab.yml
parent
7af59c54
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
100 additions
and
51 deletions
+100
-51
app/mailers/devise_mailer.rb
app/mailers/devise_mailer.rb
+2
-2
app/mailers/emails/projects.rb
app/mailers/emails/projects.rb
+1
-1
app/mailers/notify.rb
app/mailers/notify.rb
+4
-4
config/gitlab.teatro.yml
config/gitlab.teatro.yml
+5
-2
config/gitlab.yml.example
config/gitlab.yml.example
+56
-11
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+20
-4
config/initializers/disable_email_interceptor.rb
config/initializers/disable_email_interceptor.rb
+3
-1
config/initializers/email_settings.rb
config/initializers/email_settings.rb
+5
-0
config/initializers/smtp_settings.rb.sample
config/initializers/smtp_settings.rb.sample
+0
-22
lib/tasks/gitlab/check.rake
lib/tasks/gitlab/check.rake
+1
-1
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+3
-3
No files found.
app/mailers/devise_mailer.rb
View file @
b4be7aed
class
DeviseMailer
<
Devise
::
Mailer
class
DeviseMailer
<
Devise
::
Mailer
default
from:
"
#{
Gitlab
.
config
.
gitlab
.
email_display_name
}
<
#{
Gitlab
.
config
.
gitlab
.
email_
from
}
>"
default
from:
"
#{
Gitlab
.
config
.
outgoing_emails
.
display_name
}
<
#{
Gitlab
.
config
.
outgoing_emails
.
from
}
>"
default
reply_to:
Gitlab
.
config
.
gitlab
.
email_
reply_to
default
reply_to:
Gitlab
.
config
.
outgoing_emails
.
reply_to
end
end
app/mailers/emails/projects.rb
View file @
b4be7aed
...
@@ -129,7 +129,7 @@ module Emails
...
@@ -129,7 +129,7 @@ module Emails
if
send_from_committer_email
&&
can_send_from_user_email?
(
@author
)
if
send_from_committer_email
&&
can_send_from_user_email?
(
@author
)
@author
.
email
@author
.
email
else
else
Gitlab
.
config
.
gitlab
.
email_
reply_to
Gitlab
.
config
.
outgoing_emails
.
reply_to
end
end
mail
(
from:
sender
(
author_id
,
send_from_committer_email
),
mail
(
from:
sender
(
author_id
,
send_from_committer_email
),
...
...
app/mailers/notify.rb
View file @
b4be7aed
...
@@ -17,7 +17,7 @@ class Notify < ActionMailer::Base
...
@@ -17,7 +17,7 @@ class Notify < ActionMailer::Base
helper_method
:current_user
,
:can?
helper_method
:current_user
,
:can?
default
from:
Proc
.
new
{
default_sender_address
.
format
}
default
from:
Proc
.
new
{
default_sender_address
.
format
}
default
reply_to:
Gitlab
.
config
.
gitlab
.
email_
reply_to
default
reply_to:
Gitlab
.
config
.
outgoing_emails
.
reply_to
# Just send email with 2 seconds delay
# Just send email with 2 seconds delay
def
self
.
delay
def
self
.
delay
...
@@ -50,9 +50,9 @@ class Notify < ActionMailer::Base
...
@@ -50,9 +50,9 @@ class Notify < ActionMailer::Base
# The default email address to send emails from
# The default email address to send emails from
def
default_sender_address
def
default_sender_address
address
=
Mail
::
Address
.
new
(
Gitlab
.
config
.
gitlab
.
email_from
)
Mail
::
Address
.
new
(
Gitlab
.
config
.
outgoing_emails
.
from
).
tap
do
|
address
|
address
.
display_name
=
Gitlab
.
config
.
gitlab
.
email_
display_name
address
.
display_name
=
Gitlab
.
config
.
outgoing_emails
.
display_name
address
end
end
end
def
can_send_from_user_email?
(
sender
)
def
can_send_from_user_email?
(
sender
)
...
...
config/gitlab.teatro.yml
View file @
b4be7aed
...
@@ -7,8 +7,6 @@ production: &base
...
@@ -7,8 +7,6 @@ production: &base
user
:
root
user
:
root
email_from
:
example@example.com
support_email
:
support@example.com
support_email
:
support@example.com
default_projects_features
:
default_projects_features
:
...
@@ -19,6 +17,9 @@ production: &base
...
@@ -19,6 +17,9 @@ production: &base
snippets
:
false
snippets
:
false
visibility_level
:
"
private"
# can be "private" | "internal" | "public"
visibility_level
:
"
private"
# can be "private" | "internal" | "public"
outgoing_emails
:
from
:
example@example.com
issues_tracker
:
issues_tracker
:
gravatar
:
gravatar
:
...
@@ -75,6 +76,8 @@ test:
...
@@ -75,6 +76,8 @@ test:
gitlab
:
gitlab
:
host
:
localhost
host
:
localhost
port
:
80
port
:
80
outgoing_emails
:
delivery_method
:
:test
issues_tracker
:
issues_tracker
:
redmine
:
redmine
:
title
:
"
Redmine"
title
:
"
Redmine"
...
...
config/gitlab.yml.example
View file @
b4be7aed
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
# How to use:
# How to use:
# 1. Copy file as gitlab.yml
# 1. Copy file as gitlab.yml
# 2. Update gitlab -> host with your fully qualified domain name
# 2. Update gitlab -> host with your fully qualified domain name
# 3. Update
gitlab -> email_
from
# 3. Update
outgoing_emails ->
from
# 4. If you installed Git from source, change git -> bin_path to /usr/local/bin/git
# 4. If you installed Git from source, change git -> bin_path to /usr/local/bin/git
# IMPORTANT: If Git was installed in a different location use that instead.
# IMPORTANT: If Git was installed in a different location use that instead.
# You can check with `which git`. If a wrong path of Git is specified, it will
# You can check with `which git`. If a wrong path of Git is specified, it will
...
@@ -46,16 +46,6 @@ production: &base
...
@@ -46,16 +46,6 @@ production: &base
# To see all available zones, run `bundle exec rake time:zones:all RAILS_ENV=production`
# To see all available zones, run `bundle exec rake time:zones:all RAILS_ENV=production`
# time_zone: 'UTC'
# time_zone: 'UTC'
## Email settings
# Uncomment and set to false if you need to disable email sending from GitLab (default: true)
# email_enabled: true
# Email address used in the "From" field in mails sent by GitLab
email_from: example@example.com
email_display_name: GitLab
email_reply_to: noreply@example.com
# Email server smtp settings are in config/initializers/smtp_settings.rb.sample
# default_can_create_group: false # default: true
# default_can_create_group: false # default: true
# username_changing_enabled: false # default: true - User can change her username/namespace
# username_changing_enabled: false # default: true - User can change her username/namespace
## Default theme
## Default theme
...
@@ -89,6 +79,57 @@ production: &base
...
@@ -89,6 +79,57 @@ production: &base
# The default is 'tmp/repositories' relative to the root of the Rails app.
# The default is 'tmp/repositories' relative to the root of the Rails app.
# repository_downloads_path: tmp/repositories
# repository_downloads_path: tmp/repositories
## Settings for sending emails
outgoing_emails:
# Set to false if you need to disable email sending from GitLab (default: true).
enabled: true
# Email address and name used in the "From" field in mails sent by GitLab.
from: example@example.com
display_name: GitLab
# Email address used in "Reply-To" field in mails sent by GitLab.
reply_to: noreply@example.com
# Defines a delivery method. Possible values are:
# :sendmail - send emails using sendmail command (default).
# :smtp - send emails using SMTP server.
# :letter_opener - open sent emails in browser.
# :test - save emails to ActionMailer::Base.deliveries array.
delivery_method: :sendmail
# Settings for the :sendmail delivery method.
sendmail_settings:
# The location of the sendmail executable (default: /usr/sbin/sendmail).
location: /usr/sbin/sendmail
# The command line arguments to be passed to sendmail (default: -i -t).
arguments: '-i -t'
# Settings for the :smtp delivery method.
smtp_settings:
# Hostname of the SMTP server used to send emails (default: localhost).
address: localhost
# Port of the SMTP server used to send emails (default: 25).
port: 25
# If your mail server requires authentication, you need to specify the
# authentication type here. Possible values are:
# :plain - send the password in the clear text.
# :login - send password Base64 encoded.
# :cram_md5 - combines a Challenge/Response mechanism to exchange information and
# a cryptographic Message Digest 5 algorithm to hash important information.
# authentication: :plain
# user_name: 'gitlab'
# password: '123456'
# Detects if STARTTLS is enabled in your SMTP server and starts to use it.
# Set this to false if there is a problem with your server certificate
# that you cannot resolve. It should be true for Gmail SMTP.
# enable_starttls_auto: true
## Gravatar
## Gravatar
## For Libravatar see: http://doc.gitlab.com/ce/customization/libravatar.html
## For Libravatar see: http://doc.gitlab.com/ce/customization/libravatar.html
gravatar:
gravatar:
...
@@ -295,6 +336,8 @@ production: &base
...
@@ -295,6 +336,8 @@ production: &base
development:
development:
<<: *base
<<: *base
outgoing_emails:
delivery_method: :letter_opener
test:
test:
<<: *base
<<: *base
...
@@ -303,6 +346,8 @@ test:
...
@@ -303,6 +346,8 @@ test:
gitlab:
gitlab:
host: localhost
host: localhost
port: 80
port: 80
outgoing_emails:
delivery_method: :test
# When you run tests we clone and setup gitlab-shell
# When you run tests we clone and setup gitlab-shell
# In order to setup it correctly you need to specify
# In order to setup it correctly you need to specify
...
...
config/initializers/1_settings.rb
View file @
b4be7aed
...
@@ -105,10 +105,6 @@ Settings.gitlab['https'] = false if Settings.gitlab['https'].nil?
...
@@ -105,10 +105,6 @@ Settings.gitlab['https'] = false if Settings.gitlab['https'].nil?
Settings
.
gitlab
[
'port'
]
||=
Settings
.
gitlab
.
https
?
443
:
80
Settings
.
gitlab
[
'port'
]
||=
Settings
.
gitlab
.
https
?
443
:
80
Settings
.
gitlab
[
'relative_url_root'
]
||=
ENV
[
'RAILS_RELATIVE_URL_ROOT'
]
||
''
Settings
.
gitlab
[
'relative_url_root'
]
||=
ENV
[
'RAILS_RELATIVE_URL_ROOT'
]
||
''
Settings
.
gitlab
[
'protocol'
]
||=
Settings
.
gitlab
.
https
?
"https"
:
"http"
Settings
.
gitlab
[
'protocol'
]
||=
Settings
.
gitlab
.
https
?
"https"
:
"http"
Settings
.
gitlab
[
'email_enabled'
]
||=
true
if
Settings
.
gitlab
[
'email_enabled'
].
nil?
Settings
.
gitlab
[
'email_from'
]
||=
"gitlab@
#{
Settings
.
gitlab
.
host
}
"
Settings
.
gitlab
[
'email_display_name'
]
||=
"GitLab"
Settings
.
gitlab
[
'email_reply_to'
]
||=
"noreply@
#{
Settings
.
gitlab
.
host
}
"
Settings
.
gitlab
[
'url'
]
||=
Settings
.
send
(
:build_gitlab_url
)
Settings
.
gitlab
[
'url'
]
||=
Settings
.
send
(
:build_gitlab_url
)
Settings
.
gitlab
[
'user'
]
||=
'git'
Settings
.
gitlab
[
'user'
]
||=
'git'
Settings
.
gitlab
[
'user_home'
]
||=
begin
Settings
.
gitlab
[
'user_home'
]
||=
begin
...
@@ -134,6 +130,26 @@ Settings.gitlab.default_projects_features['visibility_level'] = Settings.send
...
@@ -134,6 +130,26 @@ Settings.gitlab.default_projects_features['visibility_level'] = Settings.send
Settings
.
gitlab
[
'repository_downloads_path'
]
=
File
.
absolute_path
(
Settings
.
gitlab
[
'repository_downloads_path'
]
||
'tmp/repositories'
,
Rails
.
root
)
Settings
.
gitlab
[
'repository_downloads_path'
]
=
File
.
absolute_path
(
Settings
.
gitlab
[
'repository_downloads_path'
]
||
'tmp/repositories'
,
Rails
.
root
)
Settings
.
gitlab
[
'restricted_signup_domains'
]
||=
[]
Settings
.
gitlab
[
'restricted_signup_domains'
]
||=
[]
#
# Outgoing emails
#
Settings
[
'outgoing_emails'
]
||=
Settingslogic
.
new
({})
Settings
[
'outgoing_emails'
].
tap
do
|
opts
|
# For backward compatibility. TODO remove in next major release.
opts
[
'enabled'
]
||=
Settings
.
gitlab
[
'email_enabled'
]
opts
[
'from'
]
||=
Settings
.
gitlab
[
'email_from'
]
opts
[
'display_name'
]
||=
Settings
.
gitlab
[
'display_name'
]
opts
[
'reply_to'
]
||=
Settings
.
gitlab
[
'email_reply_to'
]
opts
[
'enabled'
]
||=
opts
[
'enabled'
].
nil?
opts
[
'display_name'
]
||=
"GitLab"
opts
[
'from'
]
||=
"gitlab@
#{
Settings
.
gitlab
.
host
}
"
opts
[
'reply_to'
]
||=
"noreply@
#{
Settings
.
gitlab
.
host
}
"
opts
[
'delivery_method'
]
||=
:sendmail
opts
[
'sendmail_settings'
]
||=
{}
opts
[
'smtp_settings'
]
||=
{}
end
#
#
# Gravatar
# Gravatar
#
#
...
...
config/initializers/disable_email_interceptor.rb
View file @
b4be7aed
# Interceptor in lib/disable_email_interceptor.rb
# Interceptor in lib/disable_email_interceptor.rb
ActionMailer
::
Base
.
register_interceptor
(
DisableEmailInterceptor
)
unless
Gitlab
.
config
.
gitlab
.
email_enabled
unless
Gitlab
.
config
.
outgoing_emails
.
enabled
ActionMailer
::
Base
.
register_interceptor
(
DisableEmailInterceptor
)
end
config/initializers/email_settings.rb
0 → 100644
View file @
b4be7aed
Gitlab
.
config
.
outgoing_emails
.
tap
do
|
c
|
Gitlab
::
Application
.
config
.
action_mailer
.
delivery_method
=
c
.
delivery_method
ActionMailer
::
Base
.
smtp_settings
=
c
.
smtp_settings
.
symbolize_keys
ActionMailer
::
Base
.
sendmail_settings
=
c
.
sendmail_settings
.
symbolize_keys
end
config/initializers/smtp_settings.rb.sample
deleted
100644 → 0
View file @
7af59c54
# To enable smtp email delivery for your GitLab instance do the following:
# 1. Rename this file to smtp_settings.rb
# 2. Edit settings inside this file
# 3. Restart GitLab instance
#
# For full list of options and their values see http://api.rubyonrails.org/classes/ActionMailer/Base.html
#
if Rails.env.production?
Gitlab::Application.config.action_mailer.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
address: "email.server.com",
port: 456,
user_name: "smtp",
password: "123456",
domain: "gitlab.company.com",
authentication: :login,
enable_starttls_auto: true,
openssl_verify_mode: 'peer' # See ActionMailer documentation for other possible options
}
end
lib/tasks/gitlab/check.rake
View file @
b4be7aed
...
@@ -320,7 +320,7 @@ namespace :gitlab do
...
@@ -320,7 +320,7 @@ namespace :gitlab do
options
=
{
options
=
{
"user.name"
=>
"GitLab"
,
"user.name"
=>
"GitLab"
,
"user.email"
=>
Gitlab
.
config
.
gitlab
.
email_
from
,
"user.email"
=>
Gitlab
.
config
.
outgoing_emails
.
from
,
"core.autocrlf"
=>
"input"
"core.autocrlf"
=>
"input"
}
}
correct_options
=
options
.
map
do
|
name
,
value
|
correct_options
=
options
.
map
do
|
name
,
value
|
...
...
spec/mailers/notify_spec.rb
View file @
b4be7aed
...
@@ -5,9 +5,9 @@ describe Notify do
...
@@ -5,9 +5,9 @@ describe Notify do
include
EmailSpec
::
Matchers
include
EmailSpec
::
Matchers
include
RepoHelpers
include
RepoHelpers
let
(
:gitlab_sender_display_name
)
{
Gitlab
.
config
.
gitlab
.
email_
display_name
}
let
(
:gitlab_sender_display_name
)
{
Gitlab
.
config
.
outgoing_emails
.
display_name
}
let
(
:gitlab_sender
)
{
Gitlab
.
config
.
gitlab
.
email_
from
}
let
(
:gitlab_sender
)
{
Gitlab
.
config
.
outgoing_emails
.
from
}
let
(
:gitlab_sender_reply_to
)
{
Gitlab
.
config
.
gitlab
.
email_
reply_to
}
let
(
:gitlab_sender_reply_to
)
{
Gitlab
.
config
.
outgoing_emails
.
reply_to
}
let
(
:recipient
)
{
create
(
:user
,
email:
'recipient@example.com'
)
}
let
(
:recipient
)
{
create
(
:user
,
email:
'recipient@example.com'
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment