Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs
# editorconfig.org

root = true

[*]
indent_style = space
indent_size = 4

# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.js]
indent_size = 2

[*.xml]
indent_size = 4

[*.groovy]
indent_size = 4

[*.gsp]
indent_size = 2

[*.md]
trim_trailing_whitespace = false
indent_size = 4

[*.{yml,yaml}]
indent_size = 2

[*.json]
indent_size = 2

[*.gdoc]
indent_size = 2

[*.html]
indent_size = 2

[*.css]
indent_size = 2

[.github/release-drafter.yml]
insert_final_newline = false

[.github/renovate.json]
insert_final_newline = false

[gradle/libs.versions.toml]
insert_final_newline = false

[grails-app/i18n/*.properties]
insert_final_newline = false
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ jobs:
COMMIT_EMAIL: ${{ env.GIT_USER_EMAIL }}
COMMIT_NAME: ${{ env.GIT_USER_NAME }}
FOLDER: build/docs/manual
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/release-notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ on:
pull_request:
types: [opened, reopened, synchronize, labeled]
pull_request_target:
types: [opened, reopened, synchronize, labeled]
types: [opened, reopened, synchronize, labeled]
workflow_dispatch:
jobs:
release_notes:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Check if it has release drafter config file
id: check_release_drafter
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ jobs:

- name: Run post-release
if: steps.publish_to_sonatype.outcome == 'success'
uses: micronaut-projects/github-actions/post-release@master
uses: micronaut-projects/github-actions/post-release@master
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ The Grails mail plugin provides a convenient DSL for _sending_ email. It support
Mail can be sent using the `mailService.sendMail` method. Here is an example…
```groovy
mailService.sendMail {
to '[email protected]', '[email protected]'
from '[email protected]'
cc '[email protected]', '[email protected]'
bcc '[email protected]'
subject 'Hello John'
text 'this is some text'
to '[email protected]', '[email protected]'
from '[email protected]'
cc '[email protected]', '[email protected]'
bcc '[email protected]'
subject 'Hello John'
text 'this is some text'
}
```

Expand All @@ -40,4 +40,4 @@ Issues can be raised via [GitHub Issues](https://github.com/grails/grails-mail/i

Pull requests are the preferred method for submitting contributions. Please open an issue via that issue tracker link above and create an issue describing what your contribution addresses.

If you are contributing documentation, raising an issue is not necessary.
If you are contributing documentation, raising an issue is not necessary.
2 changes: 1 addition & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ repositories {
dependencies {
implementation buildsrcLibs.nexus.publish.gradle.plugin
implementation buildsrcLibs.grails.gradle.plugin
}
}
2 changes: 1 addition & 1 deletion buildSrc/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ dependencyResolutionManagement {
from(files('../gradle/buildsrc.libs.versions.toml'))
}
}
}
}
2 changes: 1 addition & 1 deletion gradle/documentation-config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ tasks.withType(PublishGuideTask).configureEach {
classpath = configurations.guideConfiguration
javadocDir = null
propertiesFile = layout.projectDirectory.file('src/docs/guide.properties').asFile
}
}
2 changes: 1 addition & 1 deletion gradle/grails-plugin-config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ tasks.named('jar', Jar) {
enabled = true // Enable the jar task again, as the bootJar task has been disabled
archiveClassifier = '' // Remove '-plain' suffix from jar file name
exclude('_testemails', 'messages*.properties')
}
}
2 changes: 1 addition & 1 deletion gradle/java-config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ java {
sourceCompatibility = JavaVersion.VERSION_11
withSourcesJar()
withJavadocJar()
}
}
2 changes: 1 addition & 1 deletion gradle/publishing.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,4 @@ if (isReleaseVersion) {
//do not generate extra load on Nexus with new staging repository if signing fails
tasks.withType(InitializeNexusStagingRepository).configureEach {
shouldRunAfter = tasks.withType(Sign)
}
}
2 changes: 1 addition & 1 deletion grails-app/init/grails/plugins/mail/Application.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ class Application extends GrailsAutoConfiguration {
static void main(String[] args) {
GrailsApp.run(Application)
}
}
}
58 changes: 29 additions & 29 deletions grails-app/services/grails/plugins/mail/MailService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ import java.util.concurrent.TimeUnit
@CompileStatic
class MailService implements InitializingBean, DisposableBean {

MailConfigurationProperties mailConfigurationProperties
MailConfigurationProperties mailConfigurationProperties
MailMessageBuilderFactory mailMessageBuilderFactory

private ThreadPoolExecutor mailExecutorService
private ThreadPoolExecutor mailExecutorService

private static final Integer DEFAULT_POOL_SIZE = 5
private static final Bindable<MailConfigurationProperties> CONFIG_BINDABLE = Bindable.of(MailConfigurationProperties)
private static final Integer DEFAULT_POOL_SIZE = 5
private static final Bindable<MailConfigurationProperties> CONFIG_BINDABLE = Bindable.of(MailConfigurationProperties)

MailMessage sendMail(MailConfigurationProperties properties, @DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = MailMessageBuilder) Closure callable) {
if (disabled) {
Expand All @@ -57,40 +57,40 @@ class MailService implements InitializingBean, DisposableBean {
return messageBuilder.sendMessage(mailExecutorService)
}

MailMessage sendMail(Config config, @DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = MailMessageBuilder) Closure callable) {
return sendMail(toMailProperties(config), callable)
}
MailMessage sendMail(Config config, @DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = MailMessageBuilder) Closure callable) {
return sendMail(toMailProperties(config), callable)
}

MailMessage sendMail(@DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = MailMessageBuilder) Closure callable) {
return sendMail(mailConfigurationProperties, callable)
}

private static MailConfigurationProperties toMailProperties(Config config) {
def propertySource = new PropertiesPropertySource('mailProperties', config.toProperties())
def configurationPropertySources = ConfigurationPropertySources.from(propertySource)
def binder = new Binder(configurationPropertySources)
return binder.bind(MailConfigurationProperties.PREFIX, CONFIG_BINDABLE).get()
}
private static MailConfigurationProperties toMailProperties(Config config) {
def propertySource = new PropertiesPropertySource('mailProperties', config.toProperties())
def configurationPropertySources = ConfigurationPropertySources.from(propertySource)
def binder = new Binder(configurationPropertySources)
return binder.bind(MailConfigurationProperties.PREFIX, CONFIG_BINDABLE).get()
}

boolean isDisabled() {
mailConfigurationProperties.disabled
return mailConfigurationProperties.disabled
}

void setPoolSize(Integer poolSize){
mailExecutorService.setMaximumPoolSize(poolSize ?: DEFAULT_POOL_SIZE)
mailExecutorService.setCorePoolSize(poolSize ?: DEFAULT_POOL_SIZE)
}
void setPoolSize(Integer poolSize) {
mailExecutorService.setMaximumPoolSize(poolSize ?: DEFAULT_POOL_SIZE)
mailExecutorService.setCorePoolSize(poolSize ?: DEFAULT_POOL_SIZE)
}

@Override
void destroy() throws Exception {
mailExecutorService.shutdown()
mailExecutorService.awaitTermination(10, TimeUnit.SECONDS)
}
@Override
void destroy() throws Exception {
mailExecutorService.shutdown()
mailExecutorService.awaitTermination(10, TimeUnit.SECONDS)
}

@Override
void afterPropertiesSet() throws Exception {
mailExecutorService = new ThreadPoolExecutor(1, 1, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>())
mailExecutorService.allowCoreThreadTimeOut(true)
setPoolSize(mailConfigurationProperties.poolSize)
}
@Override
void afterPropertiesSet() throws Exception {
mailExecutorService = new ThreadPoolExecutor(1, 1, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>())
mailExecutorService.allowCoreThreadTimeOut(true)
setPoolSize(mailConfigurationProperties.poolSize)
}
}
2 changes: 1 addition & 1 deletion grails-app/views/_testemails/i18ntest.gsp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%@ page contentType="text/html" %>
<html>
<body><g:message code="translate" args="${[name]}"/></body>
</html>
</html>
2 changes: 1 addition & 1 deletion src/docs/guide.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
title=Grails Mail Plugin
authors=The Grails Team
authors=The Grails Team
20 changes: 10 additions & 10 deletions src/docs/guide/1. Introduction.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ Mail can be sent using the @mailService@ via the @sendMail@ method. Here is an e

{code}
mailService.sendMail {
to "[email protected]", "ginger\@gmail.com"
from "[email protected]"
cc "[email protected]", "ed\@gmail.com"
bcc "[email protected]"
subject "Hello John"
text "this is some text"
to "[email protected]", "ginger\@gmail.com"
from "[email protected]"
cc "[email protected]", "ed\@gmail.com"
bcc "[email protected]"
subject "Hello John"
text "this is some text"
}
{code}

Expand All @@ -19,8 +19,8 @@ The @sendMail@ method is injected into all controllers to simplify access:

{code}
sendMail {
to "[email protected]"
subject "Hello Fred"
text "How are you?"
to "[email protected]"
subject "Hello Fred"
text "How are you?"
}
{code}
{code}
36 changes: 18 additions & 18 deletions src/docs/guide/2.1 SMTP Server Configuration.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@ By default the plugin assumes an unsecured mail server configured on port 25, ge

{code}
grails {
mail {
host = "smtp.gmail.com"
port = 465
username = "[email protected]"
password = "yourpassword"
props = ["mail.smtp.auth":"true",
"mail.smtp.socketFactory.port":"465",
"mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
"mail.smtp.socketFactory.fallback":"false"]
}
mail {
host = "smtp.gmail.com"
port = 465
username = "[email protected]"
password = "yourpassword"
props = ["mail.smtp.auth":"true",
"mail.smtp.socketFactory.port":"465",
"mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
"mail.smtp.socketFactory.fallback":"false"]
}
}
{code}

And the configuration for sending via a Hotmail/Live account:

{code}
grails {
mail {
host = "smtp.live.com"
port = 587
username = "[email protected]"
password = "yourpassword"
props = ["mail.smtp.starttls.enable":"true",
"mail.smtp.port":"587"]
}
mail {
host = "smtp.live.com"
port = 587
username = "[email protected]"
password = "yourpassword"
props = ["mail.smtp.starttls.enable":"true",
"mail.smtp.port":"587"]
}
}
{code}

Expand Down
2 changes: 1 addition & 1 deletion src/docs/guide/2.2 Defaults Configuration.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ You can also set the default "to" address to use for messages in Config using:

{code}
grails.mail.default.to = "[email protected]"
{code}
{code}
2 changes: 1 addition & 1 deletion src/docs/guide/3.1 Sender And Recipient.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ sendMail {

The @from@ method accepts one string value email address using the syntax of "RFC822":http://www.ietf.org/rfc/rfc822.txt. Typical address syntax is of the form @"user\@host.domain"@ or @"Personal Name <user\@host.domain>"@.

If no value is provided for @from@ when sending an email, the _default from address_ will be used.
If no value is provided for @from@ when sending an email, the _default from address_ will be used.
2 changes: 1 addition & 1 deletion src/docs/guide/3.2 Message Content.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ Both the @text@ and @html@ methods support specifying a view to render to form t

* The _view_ is the absolute path (or relative to the current controller if during a request) to the GSP, just like the existing Grails @render@ method.
* The _plugin_ parameter is only necessary if the view you wish to render comes from a plugin, just like the existing Grails @render@ method.
* The _model_ parameter is a map representing the model the GSP will see for rendering data, just like the existing Grails @render@ method.
* The _model_ parameter is a map representing the model the GSP will see for rendering data, just like the existing Grails @render@ method.
2 changes: 1 addition & 1 deletion src/docs/guide/3.3 Attachments.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ The mail plugin supports using either a @byte\[\]@, @File@, or "@InputStreamSour

In the case of the variants that take a @File@ that do not specify a content id, the name of the file will be used.

In the case of the variants that take a @File@ that do not specify a content type, the content type will be guessed based on the file extension.
In the case of the variants that take a @File@ that do not specify a content type, the content type will be guessed based on the file extension.
2 changes: 1 addition & 1 deletion src/docs/guide/4. Testing.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ The preferred approach is to use the existing "grails-greenmail":http://www.grai

The advantage of this approach is that it is as close as possible to real world and gives you access to the sent email in your tests. The disadvantage is that it is another plugin dependency.

Consult the documentation for the plugin for more information.
Consult the documentation for the plugin for more information.
Loading
Loading