SiRGt
SiRGt

Reputation: 98

How to change sender name from Gitlab emails

When I installed Gitlab on one of our servers I didn't realize that the first user would be the Gitlab Admin User and every time Gitlab sends a notification it appears that I'm the one who sends the email (only the name the email is the one in config/gitlab.yml)

How can I change that?

Thanks.

Upvotes: 2

Views: 4775

Answers (1)

VonC
VonC

Reputation: 1323743

Original answer (July 2014, GitLab 7.8.0)

You can see the sender function in app/mailers/notify.rb#L30:

# The default email address to send emails from
  def default_sender_address
    address = Mail::Address.new(Gitlab.config.gitlab.email_from)
    address.display_name = "GitLab"
    address
  end

That is the function you could change.

Update July 2016 (2 years later, GitLab 8.9.0+)

The updated code is still in app/mailers/notify.rb


Update Dec. 2018 (GitLab 11.6)

The email specs still shows:

shared_examples 'an email sent from GitLab' do
  it 'is sent from GitLab' do
    sender = subject.header[:from].addrs[0]
    expect(sender.display_name).to eq(gitlab_sender_display_name)
    expect(sender.address).to eq(gitlab_sender)
end

Which means some emails are sent with gitlab_sender_display_name, which is defined as:

let(:gitlab_sender_display_name) { Gitlab.config.gitlab.email_display_name }

Changing that gitlab.email_display_name should change the "GitLab" sender.

Harry confirms in the comments:

We now have in /config/initializers/1_settings.rb

Settings.gitlab['email_display_name'] ||= ENV['GITLAB_EMAIL_DISPLAY_NAME'] || 'GitLab'
                                                                              ^^^^^^^^

The ENV part comes from commit 82bfa8f, GitLab v8.4.0v2, Dec. 2015.

Upvotes: 3

Related Questions