Adds SMTP authentication method to custom email settings page
Feature context
Sometimes customers need to specify the authentication method explicitly (e.g. M365).
We added a new enum smtp_authentication
which defaults to nil
. So Net::SMTP
tries to figure out which AUTH method to use automatically. The EHLO
response from the SMTP handshake usually contains a list of supported AUTH
methods like this 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH
. Sometimes the server doesn't return such information or Net::SMTP
doesn't pick them or tries to use an unsupported method.
For those cases, customers may want to specify the AUTH method themselves explicitly. We can support all AUTH methods that ActionMailer
supports (plain, login, cram_md5). See Mail::SMTP
or Net::SMTP
doc for full configuration options and defaults.
Contributes to Custom email: Net::SMTP doesn't select the corr... (#429680 - closed)
Part of Configurable e-mail address for service desk (#329990 - closed)
:service_desk_custom_email
which was enabled by default in 16.4
.
What does this MR do and why?
Allows the user to select an explicit SMTP authentication method using a dropdown for Service Desk custom email on the projects settings page.
Related MRs
- Adds smtp_authentication to Service Desk Custom... (!135612 - merged) introduced the DB field and backend logic.
Follow up MRs
- Rescue
Net::SMTPAuthenticationError
(which is the error we saw whenNet::SMTP
doesn't know what to do) and add that error to the list of verification errors.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
- If you haven't set up
incoming_email
orservice_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"
- Visit
http://127.0.0.1:3000/flightjs/Flight/edit
and expand theService Desk
section. Please find the Configure a custom email address card. - (Optional) If it's not available, you probably need to enable the feature flag (enabled by default).
project = Project.find(7) Feature.enable(:service_desk_custom_email, project)
- The form should contain the form item SMTP authentication method with a dropdown with the following options:
Use method supported by the server (recommended)
Plain
Login
CRAM-MD5
- Fill in some example values. Feel free to use these:
support@example.com
-
smtp.gmail.com
(SMTP address needs to be resolvable from the public internet) 587
support@example.com
supersecret
-
Login
<-- SMTP authentication method
- Open the developer tools and select the Network tab to check the payload of the
POST
request. - Select Save and test connection. The verification will obviously fail quite fast, but we're only interested in checking whether the authentication method value is transported and saved correctly.
- The payload of the
custom_email
POST
request should containsmtp_authentication: "login"
. - Now let's check whether the value has been saved correctly. In the rails console run the following:
Project.find(7).service_desk_custom_email_credential
smtp_authentication: "login
. - (Optional) To roll back all changes, select Reset custom email or run the following snippet:
project = Project.find(7) current_user = User.first ::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.