Skip to content

Adds read_timeout to Service Desk custom email verification errors

Feature context

Custom email for Service Desk allows customers to use their own email address for support communication. They forward all emails to the project-specific service desk email address (generated from incoming_email) and provide their SMTP credential for the custom email address. We send all outgoing Service Desk emails using the provided credentials.

Before we enable this, we send a verification email to check the provided credentials work and that the service provider supports all the features we need and email forwarding is set up correctly.

What does this MR do and why?

Solves Custom Email: Rescue Net::ReadTimeout and incre... (#430209 - closed)

Feature issue Configurable e-mail address for service desk (#329990 - closed)

Adds read_timeout to Service Desk custom email verification errors.

Sometimes SMTP servers are slow to respond to requests. Now we correctly catch that error and provide the error description in the result email.

Previously the verification request would fail with a 500 error.

Related MRs

  1. Increases read timeout for Service Desk custom ... (!136721 - merged) increases the read_timeout from 5 to 7 because some SMTP servers tend to answer slowly when they receive requests with an unsupported SMTP authentication method.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After
🚫 image

How to set up and validate locally

  1. If you haven't set up incoming_email or service_desk_email for email ingestion, please add this to your gitlab.yml file in the development: section. Please restart GDK with gdk restart:
    incoming_email:
      enabled: true
      address: "incoming+%{key}@example.com"
    This will allow you to see the Service Desk section in the settings and generate project-specific email addresses.
  2. Select a project and user and enable the feature flag (should already be enabled)
    project = Project.find(7)
    current_user = User.first
    Feature.enable(:service_desk_custom_email, project)
  3. Create Service Desk custom email records and mark verification as failed with :read_timeout error
    custom_email = 'support@example.com'
    
    setting = ServiceDeskSetting.find_or_create_by!(project_id: project.id)
    setting.update!(custom_email: custom_email)
    
    credential = ServiceDesk::CustomEmailCredential.create!(
      project_id: project.id,
      smtp_address: 'smtp.gmail.com', # we need a valid smtp address
      smtp_port: 587,
      smtp_username: custom_email,
      smtp_password: 'supersecret'
    )
    
    verification = ServiceDesk::CustomEmailVerification.new(
      project_id: project.id
    )
    verification.mark_as_started!(current_user)
    verification.mark_as_failed!(:read_timeout)
  4. Open http://127.0.0.1:3000/flightjs/Flight/edit and expand the Service Desk section and find the Configure a custom email card. You should see the :read_timeout error with a short description.
  5. Open http://127.0.0.1:3000/rails/mailers/notify/service_desk_verification_result_email_for_read_timeout_error.html?locale=en to view the email preview for the Service Desk custom email verification result email. This should show the read_timeout error. When running through the verification process project owners and the person who triggered the verification will receive an email once a verification result is available.
  6. (Optional) Clean up custom email and disable flag
    ::ServiceDesk::CustomEmails::DestroyService.new(
      project: project,
      current_user: current_user
    ).execute
    # Optional because flag is enabled by default
    # Feature.disable(:service_desk_custom_email, false)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Marc Saleiko

Merge request reports