Adds custom email incorrect_forwarding_target error
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 verification should fail when usin... (#426128 - closed)
Feature issue Configurable e-mail address for service desk (#329990 - closed)
Adds incorrect_forwarding_target to Service Desk custom email verification errors.
You can add Service Desk issues using an email generated from incoming_email
and the additional alias email generated from service_desk_email
. Only the one generated from incoming_email
supports all features we need for the custom email feature. We received feedback that customers used the other email address, so I wanted to add a check and an error for this case.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Custom email configuration
Before | After |
---|---|
![]() |
Verification result email
Before | After |
---|---|
![]() |
How to set up and validate locally
- If you haven't set up
incoming_email
andservice_desk_email
for email ingestion, please add this to yourgitlab.yml
file in thedevelopment:
section. Please restart GDK withgdk restart
:incoming_email: enabled: true address: "incoming+%{key}@example.com" service_desk_email: enabled: true address: "contact+%{key}@example.com"
- Select a project and user
project = Project.find(7) current_user = User.first
- Create Service Desk custom email records and mark verification as started
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)
- Now build the verification email that has the wrong forwarding address in the
Delivered-To
header. This is the additional Service Desk alias email address. We need the Service Desk address created from theincoming_email
address. Then ingest the email and reset theverification
object. In the print you should find a line like thiserror: "incorrect_forwarding_target"
.service_desk_alias_address = project.service_desk_alias_address verification_token = verification.token email_raw = <<~EMAIL Delivered-To: #{service_desk_alias_address} To: support+verify@example.com From: Flight Support <support@example.com> Subject: Verify custom email address support@example.com for Flight Auto-Submitted: no This email is auto-generated. It verifies the ownership of the entered Service Desk custom email address and correct functionality of email forwarding. Verification token: #{verification_token} -- You're receiving this email because of your account on 127.0.0.1. EMAIL ServiceDeskEmailReceiverWorker.new.perform(email_raw) verification.reset
- 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:incorrect_forwarding_target
error with a short description that contains the correct forwarding address. - Open
http://127.0.0.1:3000/rails/mailers/notify/service_desk_verification_result_email_for_incorrect_forwarding_target_error.html?locale=en
to view the email preview for the Service Desk custom email verification result email. This should show theincorrect_forwarding_target
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. - (Optional) Clean up custom email and disable flag
::ServiceDesk::CustomEmails::DestroyService.new( project: project, current_user: current_user ).execute
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.