Cannot send E-mails in some cases

I have reported it as a bug in Gitlab Issue #30630. However, I was suggested to post it here to give a quiker response. Although, the log looks like a configuration error, I think it may be some bugs in the software. Because when I granting access to a project, the mail is received. In other cases, I cannot receive the mail. Would you give me some helps. Thank you.

Summary

Gitlab CE v.12.1.1 only sends e-mails of project access grantation. When I forgot the password, no mails are sent due to an SMTP 501 error. When I add a secondary e-mail address, it shows HTTP 500 page.

If Gitlab CE can send e-mail in some cases (I recieved such email entitled Access to the D***********G / Test Project project was granted), it shows my configuration is alright. Moreover, it shows Gitlab use different ways to send emails. Command Notify.test_email also works.

Steps to reproduce

I do not receive any e-mails from Gitlab when I apply to reset the password.

  1. Install Gitlab CE v.12.1.1 using dpkg -i ./gitlab-ce_12.1.1-ce.0_amd64.deb;
  2. Visit the home page, and fill in the sign up form. After that, change the E-mail address to a valid one in User Settings > Profile.
  3. Sign out and click Forgot your password? link in sign in form.
  4. Fill in the e-mail address you have changed and click Reset password button.

The message is If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes. but no mails are found.

I do not receive any e-mails from Gitlab and HTTP 500 page (*Whoops, something went wrong on our end. *) shown when I add a secondary e-mail address.

  1. Sign in and visit User Settings > Emails (https://*****/profile/emails).
  2. Fill in the blank of Email box, and click Add email address button. HTTP 500 occurs.
  3. Go back and click Reset Confirmation emal button of the Unverified item. HTTP 500 occurs.

Example Project

This has nothing to do with specific projects, and I use Gitlab.com can receive mail.

What is the current bug behavior?

SMTP 501 and HTTP 500 errors ocuur.

What is the expected correct behavior?

No error pages.

Relevant logs and/or screenshots

The part related to e-mails in gitlab.rb is as follows: (I replace the confidential part to asterisk charactors.

gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = 'info@sp***g.com'
gitlab_rails['gitlab_email_display_name'] = 'GitLab, SP*** Inc.'
gitlab_rails['gitlab_email_reply_to'] = 'info@sp***g.com'

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
gitlab_rails['smtp_port'] = 465 
gitlab_rails['smtp_user_name'] = "info@sp***g.com"
gitlab_rails['smtp_password'] = "afw**********2Jw"
gitlab_rails['smtp_domain'] = "sp***g.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true

###! **Can be: 'none', 'peer', 'client_once', 'fail_if_no_peer_cert'**
###! Docs: http://api.rubyonrails.org/classes/ActionMailer/Base.html
gitlab_rails['smtp_openssl_verify_mode'] = 'peer'

When I refer to forgetting my password, the production.log shows: (I replace the user name of my e-mail to asterisk charactors.

Expand for the log related to what generated by Gitlab
Started POST "/users/password" for 192.168.1.5 at 2019-08-02 04:11:35 +0000
Processing by PasswordsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"[FILTERED]", "user"=>{"email"=>"w*****gxm@qq.com"}}
[ActiveJob] [ActionMailer::DeliveryJob] [da82faef-cbce-4933-9167-34f093d2ad58] Performing ActionMailer::DeliveryJob (Job ID: da82faef-cbce-4933-9167-34f093d2ad58) from Sidekiq(mailers) with arguments: "DeviseMailer", "reset_password_instructions", "deliver_now", #<GlobalID:0x00007f520fad8af0 @uri=#>, "oG8xvmb_Dx--sX-MSWEm", {}
[ActiveJob] Enqueued ActionMailer::DeliveryJob (Job ID: da82faef-cbce-4933-9167-34f093d2ad58) to Sidekiq(mailers) with arguments: "DeviseMailer", "reset_password_instructions", "deliver_now", #<GlobalID:0x00007fad42ad9bd8 @uri=#>, "oG8xvmb_Dx--sX-MSWEm", {}
Redirected to https://192.168.1.26:8443/users/sign_in
Completed 302 Found in 332ms (ActiveRecord: 7.7ms)
Started GET "/users/sign_in" for 192.168.1.5 at 2019-08-02 04:11:36 +0000
Processing by SessionsController#new as HTML
Completed 200 OK in 62ms (Views: 40.0ms | ActiveRecord: 8.1ms)
[ActiveJob] [ActionMailer::DeliveryJob] [da82faef-cbce-4933-9167-34f093d2ad58] Sent mail to w*****gxm@qq.com (1259.6ms)
[ActiveJob] [ActionMailer::DeliveryJob] [da82faef-cbce-4933-9167-34f093d2ad58] Error performing ActionMailer::DeliveryJob (Job ID: da82faef-cbce-4933-9167-34f093d2ad58) from Sidekiq(mailers) in 1336.35ms: Net::SMTPSyntaxError (501 mail from address must be same as authorization user
):
/opt/gitlab/embedded/lib/ruby/2.6.0/net/smtp.rb:969:in `check_response'
/opt/gitlab/embedded/lib/ruby/2.6.0/net/smtp.rb:937:in `getok'
/opt/gitlab/embedded/lib/ruby/2.6.0/net/smtp.rb:837:in `mailfrom'
/opt/gitlab/embedded/lib/ruby/2.6.0/net/smtp.rb:658:in `send_message'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/mail-2.7.1/lib/mail/network/delivery_methods/smtp_connection.rb:54:in `deliver!'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/mail-2.7.1/lib/mail/network/delivery_methods/smtp.rb:101:in `block in deliver!'
/opt/gitlab/embedded/lib/ruby/2.6.0/net/smtp.rb:519:in `start'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/mail-2.7.1/lib/mail/network/delivery_methods/smtp.rb:109:in `start_smtp_session'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/mail-2.7.1/lib/mail/network/delivery_methods/smtp.rb:100:in `deliver!'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/mail-2.7.1/lib/mail/message.rb:2159:in `do_delivery'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/mail-2.7.1/lib/mail/message.rb:260:in `block in deliver'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/actionmailer-5.2.3/lib/action_mailer/base.rb:560:in `block in deliver_mail'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/notifications.rb:168:in `block in instrument'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/notifications.rb:168:in `instrument'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/actionmailer-5.2.3/lib/action_mailer/base.rb:558:in `deliver_mail'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/mail-2.7.1/lib/mail/message.rb:260:in `deliver'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/actionmailer-5.2.3/lib/action_mailer/message_delivery.rb:114:in `block in deliver_now'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/actionmailer-5.2.3/lib/action_mailer/rescuable.rb:17:in `handle_exceptions'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/actionmailer-5.2.3/lib/action_mailer/message_delivery.rb:113:in `deliver_now'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/actionmailer-5.2.3/lib/action_mailer/delivery_job.rb:16:in `perform'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activejob-5.2.3/lib/active_job/execution.rb:39:in `block in perform_now'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:109:in `block in run_callbacks'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sentry-raven-2.9.0/lib/raven/integrations/rails/active_job.rb:18:in `capture_and_reraise_with_sentry'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sentry-raven-2.9.0/lib/raven/integrations/rails/active_job.rb:12:in `block (2 levels) in included'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:118:in `instance_exec'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/i18n-1.6.0/lib/i18n.rb:297:in `with_locale'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activejob-5.2.3/lib/active_job/translation.rb:9:in `block (2 levels) in '
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:118:in `instance_exec'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activejob-5.2.3/lib/active_job/logging.rb:26:in `block (4 levels) in '
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/notifications.rb:168:in `block in instrument'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/notifications.rb:168:in `instrument'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activejob-5.2.3/lib/active_job/logging.rb:25:in `block (3 levels) in '
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activejob-5.2.3/lib/active_job/logging.rb:46:in `block in tag_logger'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/tagged_logging.rb:71:in `block in tagged'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/tagged_logging.rb:28:in `tagged'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/tagged_logging.rb:71:in `tagged'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activejob-5.2.3/lib/active_job/logging.rb:46:in `tag_logger'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activejob-5.2.3/lib/active_job/logging.rb:22:in `block (2 levels) in '
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:118:in `instance_exec'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:136:in `run_callbacks'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activejob-5.2.3/lib/active_job/execution.rb:38:in `perform_now'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activejob-5.2.3/lib/active_job/execution.rb:24:in `block in execute'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:109:in `block in run_callbacks'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activejob-5.2.3/lib/active_job/railtie.rb:28:in `block (4 levels) in '
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/execution_wrapper.rb:87:in `wrap'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/reloader.rb:73:in `block in wrap'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/execution_wrapper.rb:83:in `wrap'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/reloader.rb:72:in `wrap'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activejob-5.2.3/lib/active_job/railtie.rb:27:in `block (3 levels) in '
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:118:in `instance_exec'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:136:in `run_callbacks'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activejob-5.2.3/lib/active_job/execution.rb:22:in `execute'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activejob-5.2.3/lib/active_job/queue_adapters/sidekiq_adapter.rb:42:in `perform'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:192:in `execute_job'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:165:in `block (2 levels) in process'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/middleware/chain.rb:128:in `block in invoke'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/metrics/sidekiq_middleware.rb:15:in `block in call'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/metrics/transaction.rb:57:in `run'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/metrics/sidekiq_middleware.rb:15:in `call'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/middleware/chain.rb:130:in `block in invoke'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/sidekiq_status/server_middleware.rb:7:in `call'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/middleware/chain.rb:130:in `block in invoke'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/sidekiq_middleware/correlation_logger.rb:10:in `block in call'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/gitlab-labkit-0.3.0/lib/labkit/correlation/correlation_id.rb:18:in `use_id'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/sidekiq_middleware/correlation_logger.rb:9:in `call'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/middleware/chain.rb:130:in `block in invoke'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/sidekiq_middleware/batch_loader.rb:7:in `call'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/middleware/chain.rb:130:in `block in invoke'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/sidekiq_middleware/request_store_middleware.rb:8:in `call'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/middleware/chain.rb:130:in `block in invoke'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/sidekiq_middleware/memory_killer.rb:18:in `call'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/middleware/chain.rb:130:in `block in invoke'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sentry-raven-2.9.0/lib/raven/integrations/sidekiq.rb:9:in `call'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/middleware/chain.rb:130:in `block in invoke'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/middleware/chain.rb:133:in `invoke'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:164:in `block in process'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:137:in `block (6 levels) in dispatch'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/job_retry.rb:109:in `local'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:136:in `block (5 levels) in dispatch'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/rails.rb:43:in `block in call'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/execution_wrapper.rb:87:in `wrap'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/reloader.rb:73:in `block in wrap'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/execution_wrapper.rb:87:in `wrap'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/reloader.rb:72:in `wrap'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/rails.rb:42:in `call'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:132:in `block (4 levels) in dispatch'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:250:in `stats'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:127:in `block (3 levels) in dispatch'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/sidekiq_logging/structured_logger.rb:16:in `call'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:126:in `block (2 levels) in dispatch'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/job_retry.rb:74:in `global'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:125:in `block in dispatch'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/logging.rb:48:in `with_context'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/logging.rb:42:in `with_job_hash_context'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:124:in `dispatch'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:163:in `process'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:83:in `process_one'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:71:in `run'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/util.rb:16:in `watchdog'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/util.rb:25:in `block in safe_thread'
Started GET "/-/metrics" for 127.0.0.1 at 2019-08-02 04:11:44 +0000
Processing by MetricsController#index as HTML
Completed 200 OK in 5ms (Views: 0.4ms | ActiveRecord: 0.0ms)
Started GET "/-/metrics" for 127.0.0.1 at 2019-08-02 04:11:59 +0000
Processing by MetricsController#index as HTML
Completed 200 OK in 6ms (Views: 0.4ms | ActiveRecord: 0.0ms)
Started GET "/-/metrics" for 127.0.0.1 at 2019-08-02 04:12:14 +0000
Processing by MetricsController#index as HTML
Completed 200 OK in 17ms (Views: 0.7ms | ActiveRecord: 0.0ms)
[ActiveJob] [ActionMailer::DeliveryJob] [da82faef-cbce-4933-9167-34f093d2ad58] Performing ActionMailer::DeliveryJob (Job ID: da82faef-cbce-4933-9167-34f093d2ad58) from Sidekiq(mailers) with arguments: "DeviseMailer", "reset_password_instructions", "deliver_now", #<GlobalID:0x00007f520fdc9b88 @uri=#>, "oG8xvmb_Dx--sX-MSWEm", {}
[ActiveJob] [ActionMailer::DeliveryJob] [da82faef-cbce-4933-9167-34f093d2ad58] Sent mail to w*****gxm@qq.com (503.5ms)
[ActiveJob] [ActionMailer::DeliveryJob] [da82faef-cbce-4933-9167-34f093d2ad58] Error performing ActionMailer::DeliveryJob (Job ID: da82faef-cbce-4933-9167-34f093d2ad58) from Sidekiq(mailers) in 547.87ms: Net::SMTPSyntaxError (501 mail from address must be same as authorization user
):
/opt/gitlab/embedded/lib/ruby/2.6.0/net/smtp.rb:969:in `check_response'
/opt/gitlab/embedded/lib/ruby/2.6.0/net/smtp.rb:937:in `getok'
/opt/gitlab/embedded/lib/ruby/2.6.0/net/smtp.rb:837:in `mailfrom'
/opt/gitlab/embedded/lib/ruby/2.6.0/net/smtp.rb:658:in `send_message'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/mail-2.7.1/lib/mail/network/delivery_methods/smtp_connection.rb:54:in `deliver!'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/mail-2.7.1/lib/mail/network/delivery_methods/smtp.rb:101:in `block in deliver!'
/opt/gitlab/embedded/lib/ruby/2.6.0/net/smtp.rb:519:in `start'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/mail-2.7.1/lib/mail/network/delivery_methods/smtp.rb:109:in `start_smtp_session'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/mail-2.7.1/lib/mail/network/delivery_methods/smtp.rb:100:in `deliver!'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/mail-2.7.1/lib/mail/message.rb:2159:in `do_delivery'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/mail-2.7.1/lib/mail/message.rb:260:in `block in deliver'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/actionmailer-5.2.3/lib/action_mailer/base.rb:560:in `block in deliver_mail'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/notifications.rb:168:in `block in instrument'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/notifications.rb:168:in `instrument'
...
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/reloader.rb:72:in `wrap'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/rails.rb:42:in `call'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:132:in `block (4 levels) in dispatch'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:250:in `stats'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:127:in `block (3 levels) in dispatch'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/sidekiq_logging/structured_logger.rb:16:in `call'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:126:in `block (2 levels) in dispatch'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/job_retry.rb:74:in `global'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:125:in `block in dispatch'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/logging.rb:48:in `with_context'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/logging.rb:42:in `with_job_hash_context'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:124:in `dispatch'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:163:in `process'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:83:in `process_one'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:71:in `run'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/util.rb:16:in `watchdog'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/util.rb:25:in `block in safe_thread'
Started GET "/-/metrics" for 127.0.0.1 at 2019-08-02 04:12:29 +0000
Processing by MetricsController#index as HTML
Completed 200 OK in 12ms (Views: 0.5ms | ActiveRecord: 0.0ms)

When I refer to adding a secondary e-mail, the production.log shows: (I replace the user name of my e-mail to asterisk charactors.

Expand for the log related to what generated by Gitlab
Started PUT "/profile/emails/2/resend_confirmation_instructions" for 192.168.1.5 at 2019-08-02 02:22:08 +0000
Processing by Profiles::EmailsController#resend_confirmation_instructions as HTML
  Parameters: {"authenticity_token"=>"[FILTERED]", "id"=>"2"}
Sent mail to y****7@163.com (624.1ms)
Completed 500 Internal Server Error in 662ms (ActiveRecord: 2.2ms)

Net::SMTPSyntaxError (501 mail from address must be same as authorization user
):

app/services/emails/confirm_service.rb:6:in execute' app/controllers/profiles/emails_controller.rb:30:in resend_confirmation_instructions’
lib/gitlab/session.rb:11:in with_session' app/controllers/application_controller.rb:445:in set_session_storage’
lib/gitlab/i18n.rb:55:in with_locale' lib/gitlab/i18n.rb:61:in with_user_locale’
app/controllers/application_controller.rb:439:in set_locale' lib/gitlab/middleware/rails_queue_duration.rb:27:in call’
lib/gitlab/metrics/rack_middleware.rb:17:in block in call' lib/gitlab/metrics/transaction.rb:57:in run’
lib/gitlab/metrics/rack_middleware.rb:17:in call' lib/gitlab/middleware/multipart.rb:103:in call’
lib/gitlab/request_profiler/middleware.rb:16:in call' lib/gitlab/middleware/go.rb:20:in call’
lib/gitlab/etag_caching/middleware.rb:13:in call' lib/gitlab/middleware/correlation_id.rb:16:in block in call’
lib/gitlab/middleware/correlation_id.rb:15:in call' lib/gitlab/middleware/read_only/controller.rb:40:in call’
lib/gitlab/middleware/read_only.rb:18:in call' lib/gitlab/middleware/basic_health_check.rb:25:in call’
lib/gitlab/request_context.rb:26:in call' lib/gitlab/metrics/requests_rack_middleware.rb:29:in call’
lib/gitlab/middleware/release_env.rb:12:in `call’

Output of checks

This bug does not happen on GitLab.com.

Results of GitLab environment info

Expand for output related to GitLab environment info
System information
System:         Ubuntu 18.04
Current User:   git
Using RVM:      no
Ruby Version:   2.6.3p62
Gem Version:    2.7.9
Bundler Version:1.17.3
Rake Version:   12.3.2
Redis Version:  3.2.12
Git Version:    2.21.0
Sidekiq Version:5.2.7
Go Version:     unknown

GitLab information
Version: 12.1.1
Revision: f9abaa7d833
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: PostgreSQL
DB Version: 10.7
URL: https://192.168.1.26:8443
HTTP Clone URL: https://192.168.1.26:8443/some-group/some-project.git
SSH Clone URL: git@192.168.1.26:some-group/some-project.git
Using LDAP: no
Using Omniauth: yes
Omniauth Providers:

GitLab Shell
Version: 9.3.0
Repository storage paths:

  • default: /var/opt/gitlab/git-data/repositories
    GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell
    Git: /opt/gitlab/embedded/bin/git

Results of GitLab application Check

Expand for output related to the GitLab application check
Checking GitLab subtasks ...

Checking GitLab Shell …

GitLab Shell: … GitLab Shell version >= 9.3.0 ? … OK (9.3.0)
Running /opt/gitlab/embedded/service/gitlab-shell/bin/check
Check GitLab API access: OK
Redis available via internal API: OK

Access to /var/opt/gitlab/.ssh/authorized_keys: OK
gitlab-shell self-check successful

Checking GitLab Shell … Finished

Checking Gitaly …

Gitaly: … default … OK

Checking Gitaly … Finished

Checking Sidekiq …

Sidekiq: … Running? … yes
Number of Sidekiq processes … 1

Checking Sidekiq … Finished

Checking Incoming Email …

Incoming Email: … Reply by email is disabled in config/gitlab.yml

Checking Incoming Email … Finished

Checking LDAP …

LDAP: … LDAP is disabled in config/gitlab.yml

Checking LDAP … Finished

Checking GitLab App …

Git configured correctly? … yes
Database config exists? … yes
All migrations up? … yes
Database contains orphaned GroupMembers? … no
GitLab config exists? … yes
GitLab config up to date? … yes
Log directory writable? … yes
Tmp directory writable? … yes
Uploads directory exists? … yes
Uploads directory has correct permissions? … yes
Uploads directory tmp has correct permissions? … skipped (no tmp uploads folder yet)
Init script exists? … skipped (omnibus-gitlab has no init script)
Init script up-to-date? … skipped (omnibus-gitlab has no init script)
Projects have namespace: …
1/1 … yes
Redis version >= 2.8.0? … yes
Ruby version >= 2.5.3 ? … yes (2.6.3)
Git version >= 2.21.0 ? … yes (2.21.0)
Git user has default SSH configuration? … yes
Active users: … 2

Checking GitLab App … Finished

Checking GitLab subtasks … Finished

Possible fixes

Sorry, I don’t know ruby language.