{"id":35157765,"url":"https://github.com/gpc/greenmail","last_synced_at":"2025-12-28T17:05:23.635Z","repository":{"id":51386885,"uuid":"1736640","full_name":"gpc/greenmail","owner":"gpc","description":"Adds an in memory SMTP server to grails apps for testing email sending","archived":false,"fork":false,"pushed_at":"2023-08-23T10:08:18.000Z","size":273,"stargazers_count":13,"open_issues_count":0,"forks_count":27,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-03-25T23:20:39.323Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://grails.org/plugin/greenmail","language":"Groovy","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gpc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-05-12T03:36:53.000Z","updated_at":"2023-01-24T07:07:23.000Z","dependencies_parsed_at":"2023-02-13T23:16:30.105Z","dependency_job_id":null,"html_url":"https://github.com/gpc/greenmail","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/gpc/greenmail","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gpc%2Fgreenmail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gpc%2Fgreenmail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gpc%2Fgreenmail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gpc%2Fgreenmail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gpc","download_url":"https://codeload.github.com/gpc/greenmail/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gpc%2Fgreenmail/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28101618,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-28T02:00:05.685Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-28T17:05:08.686Z","updated_at":"2025-12-28T17:05:23.612Z","avatar_url":"https://github.com/gpc.png","language":"Groovy","funding_links":[],"categories":[],"sub_categories":[],"readme":"Greenmail Plugin for Grails 5\n=============================\n\nThis is a fork of grails greenmail plugin for grails 5.\n\nINSTALL\n-------\n\nAdd a dependency for the plugin in `build.gradle`:\n\n```groovy\ndependencies {\n    testImplementation 'io.github.gpc:greenmail:5.0.0'\n    \n}\n```\n\nIf you need to type your `MimeMessages` you also need to depend on:\n```groovy\n    testImplementation 'jakarta.mail:jakarta.mail-api:1.6.7'\n```\n\nUSAGE\n-------\n\nProvides a wrapper around [GreenMail](https://greenmail-mail-test.github.io/greenmail/) and provides a view that displays `sent` messages - useful for testing application in the `development` or `test` environments.\n\n\n\nThe plugin assumes that you have some sort of Java mail provider installed (for instance the Grails mail plugin). You need to define an SMTP port for the mock Greenmail SMTP server to start with. Using the Grails Mail plugin, this is as simple as defining the `grails.mail.port` property in `application.yml`, like this (see the first line in the `development` and `test` blocks):\n\nYou can completely disable the plugin by using the config setting `grails.plugin.greenmail.disabled = true`.\n\nIf you need to change the default listening port (3025) you can use the `grails.plugin.greenmail.ports.smtp`\nconfiguration variable.\n\n#### Example configuration:\n\n```yaml\n--- # Mail and GreenMail configurations\nenvironments:\n    development:\n        grails:\n            mail:\n                port: 3025 # Use default GreenMail port\n    test:\n        grails:\n            plugin:\n                greenmail:\n                    ports:\n                        smtp: 2525 # Specify GreenMail port\n            mail:\n                port: \"${grails.plugin.greenmail.ports.smtp}\"\n    production:\n        grails:\n            plugin:\n                greenmail:\n                    disabled: true # Will not run the GreenMail plugin\n            mail: # For your production SMTP server. See mail plugin for configuration options\n                server: smtp.example.com\n                port: 25\n```\n\n### Usage in Integration Tests\n\nThe plugin can be used to capture email messages during integration tests. For example:\n\n```groovy\n\nimport com.icegreen.greenmail.util.GreenMailUtil\nimport grails.plugin.greenmail.GreenMail\nimport grails.plugins.mail.MailService\nimport grails.testing.mixin.integration.Integration\nimport spock.lang.Specification\n\nimport javax.mail.internet.MimeMessage\n\n@Integration\nclass GreenmailExampleSpec extends Specification {\n\n    MailService mailService\n    GreenMail greenMail\n\n    void cleanup() {\n        greenMail.deleteAllMessages()\n    }\n\n    void \"send a test mail\"() {\n        given:\n        Map mail = [message: 'hello world', from: 'from@piragua.com', to: 'to@piragua.com', subject: 'subject']\n\n        when:\n        mailService.sendMail {\n            to mail.to\n            from mail.from\n            subject mail.subject\n            body mail.message\n        }\n\n        then:\n        greenMail.receivedMessages.length == 1\n\n        with(greenMail.receivedMessages[0]) { MimeMessage message -\u003e\n            GreenMailUtil.getBody(message) == mail.message\n            GreenMailUtil.getAddressList(message.from) == mail.from\n            message.subject == mail.subject\n        }\n    }\n\n}\n```\n\n#### Test example\n\nThe above code snippets can be found here: https://github.com/sbglasius/greenmail-example\n\n### Additional methods \n\n`grails.plugin.greenmail.GreenMail` extends from `com.icegreen.greenmail.util.GreenMail` and adds a few extra methods. See [GreenMail.groovy](src/main/groovy/grails/plugin/greenmail/GreenMail.groovy) for reference.\n\n### Usage in running application \n\nThe plugin provides a controller and view to show messages that are `sent` from the application.  Simply browse to http://localhost:8080/greenmail, and it will show a list of messages sent.  You can click on the `show` link to view the raw message.\n\n\n### Roadmap\nThis is a fully functional plugin, though there are some features that I think would be worth adding.  Contributions and patches are welcome!  \n\n* Messages sent by the Grails Mail plugin have duplicate _TO:_ fields in the raw message and in the address list, for instance if the recipient is _spam@piragua.com_, then that email address is listed twice when you retrieve the address list for `RecipientType.TO` (e.g. `GreenMailUtil.getAddressList(message.getRecipients(javax.mail.Message.RecipientType.TO))`\n* Ability to view HTML email messages as they appear in a mail client rather than as RAW message.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgpc%2Fgreenmail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgpc%2Fgreenmail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgpc%2Fgreenmail/lists"}