Skip to content
This repository was archived by the owner on Jun 15, 2026. It is now read-only.

fix: mailgun 401 error#55

Merged
RMCampos merged 1 commit into
mainfrom
hotfix/mailgun-401-error
May 15, 2026
Merged

fix: mailgun 401 error#55
RMCampos merged 1 commit into
mainfrom
hotfix/mailgun-401-error

Conversation

@RMCampos

Copy link
Copy Markdown
Owner

This pull request refactors the email service integration for Mailgun in the backend, replacing the legacy RestTemplate-based implementation with the newer RestClient API. It also updates the related tests and environment variable handling to align with these changes.

Mailgun Email Service Refactor:

  • Migrated MailgunEmailService from using RestTemplate to the modern RestClient API, simplifying HTTP request handling and improving error logging. The constructor now takes a RestClient.Builder and sets up base URL, authentication, and error handling directly. [1] [2]
  • Refactored the sendEmail method to use restClient's fluent API for sending emails, removing manual header and entity construction, and improving error handling for both HTTP and unexpected exceptions. [1] [2]

Testing Updates:

  • Updated MailgunEmailServiceTest to mock RestClient and its builder, replacing all RestTemplate usage and verifications. Introduced a helper method to set up the mock call chain for the new client. [1] [2] [3] [4] [5]

Dependency and Environment Variable Adjustments:

  • Removed the unused spring-boot-starter-mail dependency from pom.xml since Mailgun is now handled directly via HTTP.
  • Updated the Docker startup script to pass MAILGUN_APIKEY and SECURITY_KEY as environment variables for the server container.

@RMCampos RMCampos self-assigned this May 15, 2026
@RMCampos RMCampos merged commit d6cb1e9 into main May 15, 2026
2 checks passed
@RMCampos RMCampos deleted the hotfix/mailgun-401-error branch May 15, 2026 17:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant