{"id":18378406,"url":"https://github.com/choonchernlim/spring-boot-mail","last_synced_at":"2025-04-06T22:32:18.537Z","repository":{"id":147258065,"uuid":"92972831","full_name":"choonchernlim/spring-boot-mail","owner":"choonchernlim","description":"Email module for sending emails.","archived":false,"fork":false,"pushed_at":"2019-02-11T19:11:44.000Z","size":57,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-22T07:42:30.239Z","etag":null,"topics":["groovy","java","maven","spring","spring-boot"],"latest_commit_sha":null,"homepage":"","language":"Groovy","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/choonchernlim.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-31T17:47:23.000Z","updated_at":"2019-01-19T23:39:17.000Z","dependencies_parsed_at":"2024-06-13T09:04:36.531Z","dependency_job_id":null,"html_url":"https://github.com/choonchernlim/spring-boot-mail","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choonchernlim%2Fspring-boot-mail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choonchernlim%2Fspring-boot-mail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choonchernlim%2Fspring-boot-mail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choonchernlim%2Fspring-boot-mail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/choonchernlim","download_url":"https://codeload.github.com/choonchernlim/spring-boot-mail/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247563901,"owners_count":20958971,"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","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":["groovy","java","maven","spring","spring-boot"],"created_at":"2024-11-06T00:33:31.055Z","updated_at":"2025-04-06T22:32:18.525Z","avatar_url":"https://github.com/choonchernlim.png","language":"Groovy","funding_links":[],"categories":[],"sub_categories":[],"readme":"# spring-boot-mail [![Build Status](https://travis-ci.org/choonchernlim/spring-boot-mail.svg?branch=master)](https://travis-ci.org/choonchernlim/spring-boot-mail) [![codecov](https://codecov.io/gh/choonchernlim/spring-boot-mail/branch/master/graph/badge.svg)](https://codecov.io/gh/choonchernlim/spring-boot-mail)\n\nEmail module for sending emails.\n \n* Works with Groovy and Java.\n* Works with Spring Boot and regular Spring.\n\nThis will be the last email service I will ever write in my whole lifetime.\n\n## Maven Dependency\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.choonchernlim\u003c/groupId\u003e\n    \u003cartifactId\u003espring-boot-mail\u003c/artifactId\u003e\n    \u003cversion\u003e0.1.4\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## MailBean Properties\n\n|Property                  |Required? |Description                                                                                                         |\n|--------------------------|----------|--------------------------------------------------------------------------------------------------------------------|\n|from                      |Yes       |Sender email.                                                                                                       |\n|tos                       |Yes       |Recipient email(s).                                                                                            |\n|subject                   |Yes       |Subject line.                                                                                                       |\n|text                      |Yes       |Email message.                                                                                                      |\n|replyTo                   |No        |Email for user to reply to. \u003cbr/\u003e\u003cbr/\u003eDefault is value from `from` property.                                        |\n|ccs                       |No        |Carbon copy emails.                                                                                                 |\n|bccs                      |No        |Blind carbon copy emails.                                                                                           |\n|attachments               |No        |Map of attachments when `key` is the filename and extension and `value` is the file.                                |\n|isHtmlText                |No        |`true` to render message as HTML, otherwise `false` to render message as plain text. \u003cbr/\u003e\u003cbr/\u003eDefault is `false`.  | \n\n## MailService API\n\n|Method                                  |Description                                                                                                       |\n|----------------------------------------|------------------------------------------------------------------------------------------------------------------|\n|`send(MailBean)`                        |Sends email.                                                                                                      |\n|`sendException(MailBean, Exception)`    |Sends email where email message contains `mailBean.text` and properly formatted caught exception.                 |\n|`sendWebException(MailBean, Exception)` |Sends email where email message contains `mailBean.text`, properly formatted caught exception and pertinent information from `HttpServletRequest` object for debugging purpose. |\n\n\nThe email message will be formatted accordingly based on `mailBean.isHtmlText`.\n\n## Usage\n\n### With Spring Boot\n\nSpring Boot automatically supplies `JavaMailSender` if any `spring.mail` namespace exists.\n\n##### `application.yml`\n\nTypically, all you need is to specify your institution's SMTP hostname:-\n\n```yml\nspring.mail.host: [YOUR_SMTP_HOST]\n```\n\n... or, if you are using Google Mail:-\n\n```yml\nspring.mail:\n  host: smtp.gmail.com\n  username: [YOUR_EMAIL]@gmail.com\n  password: [YOUR_PASSWORD]\n  properties.mail.smtp:\n    auth: true\n    socketFactory:\n      port: 465\n      class: javax.net.ssl.SSLSocketFactory\n      fallback: false\n```\n\n... but to get it working properly using Google Mail, go to https://myaccount.google.com/secureaccount first and set \"Allow less secure apps\" to \"ON\".\n\n##### Spring Configuration\n\nCreate a Spring Configuration that imports `SpringBootMailConfig`:-\n\n```groovy\n@Configuration\n@Import(SpringBootMailConfig)\nclass AppConfig {\n}\n```\n\n### Without Spring Boot\n\nBesides importing `SpringBootMailConfig`, you also have to supply `JavaMailSender` with all the mail properties:-\n\n```groovy\n@Configuration\n@Import(SpringBootMailConfig)\nclass AppConfig {\n    @Bean\n    JavaMailSender javaMailSender() {\n        new JavaMailSenderImpl(\n                host: [YOUR_SMTP_HOST]\n        )\n    }\n}\n```\n\n### Sending Mail\n\nAt the simplest level, this is all you need to send an email:-\n\n```groovy\n@Autowired\nMailService mailService\n\nmailService.send(MailBean.builder().\n                     from('from@github.com').\n                     tos(['to@github.com'] as Set).\n                     subject('subject').\n                     text('text').\n                     build())\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchoonchernlim%2Fspring-boot-mail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchoonchernlim%2Fspring-boot-mail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchoonchernlim%2Fspring-boot-mail/lists"}