Skip to content

Conversation

abhishekr700
Copy link
Owner

This commit introduces a new implementation for the Mail Service that allows sending emails via an external SMTP server. This functionality is controlled by the environment variable.

Key changes include:

  • : Updated to include the method which uses to construct and send MIME messages. It handles various scenarios including different body types (text, HTML), attachments, and custom headers.
  • : A new helper class to abstract system environment variable access, allowing for easier testing and mocking.
  • : A comprehensive new test suite for the SMTP mail service, covering core functionality, MIME structure, headers, configuration, and error handling.
  • : Updated to include necessary dependencies for testing, such as .

The new implementation provides a more flexible and robust way to send emails from App Engine applications, especially in environments where the native App Engine Mail API is not available.

This commit introduces a new implementation for the Mail Service that allows sending emails via an external SMTP server. This functionality is controlled by the  environment variable.

Key changes include:
- : Updated to include the  method which uses  to construct and send MIME messages. It handles various scenarios including different body types (text, HTML), attachments, and custom headers.
- : A new helper class to abstract system environment variable access, allowing for easier testing and mocking.
- : A comprehensive new test suite for the SMTP mail service, covering core functionality, MIME structure, headers, configuration, and error handling.
- : Updated to include necessary dependencies for testing, such as .

The new implementation provides a more flexible and robust way to send emails from App Engine applications, especially in environments where the native App Engine Mail API is not available.
Introduced an  interface to abstract the retrieval of environment variables for the SMTP mail service.

Key changes:
- Created a new  interface with  methods.
- Refactored  to implement the new  interface.
- Updated  to depend on the  interface instead of the concrete  class.

This change allows for easier mocking of environment variables in tests, improving the overall testability of the mail service and promoting a more decoupled design.
Prefixed all SMTP-related environment variables (e.g., , ) with  to improve namespacing and prevent potential conflicts.

The implementation in  and the corresponding mocks in  have been updated to use the new variable names.
Refactored the MailService to use the Strategy pattern, addressing reviewer feedback to create a more modular and testable design. The mail sending logic is now split into two distinct strategies: the legacy App Engine API and the new SMTP implementation.

Key changes:
- Renamed the original  to  to clarify that it uses the traditional App Engine API.
- Created a new  to encapsulate all logic for sending email via an external SMTP server.
- Updated  to act as a factory. It now checks the  environment variable to determine which  implementation ( or ) to provide.
- Reorganized the tests to match the new structure:
    - Renamed  to  to focus exclusively on the SMTP implementation.
    - Created  to verify the factory's selection logic.

This new structure improves adherence to the Single Responsibility and Open/Closed principles, making the system more scalable and easier to maintain.
Updated the mail service test in the  module to reflect the recent refactoring. This test was failing in the CI environment because it was still referencing the old  class.

- Renamed  to .
- Updated the test class to instantiate and test .

This change resolves the build failures observed in the GitHub workflow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant