Skip to content

Lift 256 character limit on alternative field #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
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
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Build

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
90 changes: 90 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Release
on:
release:
types: [ published ]
jobs:
release:
runs-on: ubuntu-latest
env:
GIT_USER_NAME: ${{ secrets.GIT_USER_NAME }}
GIT_USER_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
token: ${{ secrets.GH_TOKEN }}
- uses: gradle/wrapper-validation-action@v1
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 8
- name: Get latest release version number
id: get_version
uses: battila7/get-version-action@v2
- name: Run pre-release
uses: micronaut-projects/github-actions/pre-release@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to Sonatype OSSRH
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }}
SECRING_FILE: ${{ secrets.SECRING_FILE }}
RELEASE_VERSION: ${{ steps.get_version.outputs.version-without-v }}
run: |
echo "${SECRING_FILE}" | base64 -d > "${GITHUB_WORKSPACE}/secring.gpg"
echo "Publishing Artifacts for $RELEASE_VERSION"
(set -x; ./gradlew -Pversion="${RELEASE_VERSION}" -Psigning.secretKeyRingFile="${GITHUB_WORKSPACE}/secring.gpg" publishToSonatype closeAndReleaseSonatypeStagingRepository --no-daemon)
- name: Bump patch version by one
uses: actions-ecosystem/action-bump-semver@v1
id: bump_semver
with:
current_version: ${{steps.get_version.outputs.version-without-v }}
level: patch
- name: Set version in gradle.properties
env:
NEXT_VERSION: ${{ steps.bump_semver.outputs.new_version }}
run: |
echo "Preparing next snapshot"
./gradlew snapshotVersion -Pversion="${NEXT_VERSION}"
- name: Commit & Push changes
uses: actions-js/push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
author_name: ${{ secrets.GIT_USER_NAME }}
author_email: $${ secrets.GIT_USER_EMAIL }}
message: 'Set version to next SNAPSHOT'
- name: Check file documentation exists
id: check_documentation
uses: andstor/file-existence-action@v1
with:
files: "src/docs"
- name: Build documentation
if: steps.check_documentation.outputs.files_exists == 'true'
env:
RELEASE_VERSION: ${{ steps.get_version.outputs.version-without-v }}
run: |
./gradlew asciidoctor -Pversion="${RELEASE_VERSION}"
- name: Export Gradle Properties
uses: micronaut-projects/github-actions/export-gradle-properties@master
- name: Publish to Github Pages
if: steps.check_documentation.outputs.files_exists == 'true' && success()
uses: micronaut-projects/github-pages-deploy-action@master
env:
BETA: ${{ steps.get_version.outputs.isPrerelase }}
TARGET_REPOSITORY: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
BRANCH: gh-pages
FOLDER: build/asciidoc
DOC_FOLDER: latest
COMMIT_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
COMMIT_NAME: ${{ secrets.GIT_USER_NAME }}
VERSION: ${{ steps.get_version.outputs.version-without-v }}
- name: Run post-release
if: success()
uses: micronaut-projects/github-actions/post-release@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
23 changes: 23 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Mark stale issues and pull requests

on:
schedule:
- cron: '00 06 * * 1'

jobs:
stale:

runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write

steps:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue looks like it is stale and therefor it is in risk of being closed with no further action.'
stale-pr-message: 'This pull request looks like it is stale and therefor it is in risk of being closed with no further action.'
stale-issue-label: 'no-issue-activity'
stale-pr-label: 'no-pr-activity'
days-before-stale: 180
80 changes: 37 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The Grails Asynchronous Mail plugin
====================================

[![Build Status](https://travis-ci.org/kefirfromperm/grails-asynchronous-mail.svg?branch=master)](https://travis-ci.org/kefirfromperm/grails-asynchronous-mail) [![Download](https://api.bintray.com/packages/kefirsf/plugins/asynchronous-mail/images/download.svg) ](https://bintray.com/kefirsf/plugins/asynchronous-mail/_latestVersion) [![OpenHUB](https://openhub.net/p/grails-asynchronous-mail/widgets/project_thin_badge?format=gif)](https://openhub.net/p/grails-asynchronous-mail)
[![Build](https://github.com/gpc/grails-asynchronous-mail/actions/workflows/build.yml/badge.svg)](https://github.com/gpc/grails-asynchronous-mail/actions/workflows/build.yml)

Description
-----------
Expand All @@ -11,28 +11,36 @@ database with Grails domain classes and sends them by a scheduled Quartz job. Ma
the `sendAsynchronousMail` (or `sendMail`) method returning instantly, is not waiting for the mail to be actually sent. If
the SMTP server isn't available, or other errors occur, the plugin can be set to retry later.

The plugin depends on the [quartz](https://grails.org/plugins.html#plugin/quartz) and the [mail](https://grails.org/plugins.html#plugin/mail) plugins. You also need a persistence provider plugin, [hibernate4](https://grails.org/plugins.html#plugin/hibernate4) and [mongodb](https://grails.org/plugins.html#plugin/mongodb) are supported.
The plugin depends on the [quartz](https://plugins.grails.org/plugin/grails/quartz) and the [mail](https://plugins.grails.org/plugin/grails/mail) plugins. You also need a persistence provider plugin, [hibernate5](https://plugins.grails.org/plugin/grails/hibernate5) (or the appropriate version of hibernate for previous grails versions) and [mongodb](https://plugins.grails.org/plugin/grails/mongodb) are supported.

Links
-----

* The plugin page: <https://grails.org/plugins.html#plugin/asynchronous-mail>
* The VCS repository (GitHub): <https://github.com/kefirfromperm/grails-asynchronous-mail>
* The issue tracker (GitHub): <https://github.com/kefirfromperm/grails-asynchronous-mail/issues>
* The repository package (BinTray): <https://bintray.com/kefirsf/plugins/asynchronous-mail/>
* The page at OpenHUB: <https://www.openhub.net/p/grails-asynchronous-mail>
* The plugin page: <https://plugins.grails.org/plugin/grails/asynchronous-mail>
* The VCS repository (GitHub): <https://github.com/gpc/grails-asynchronous-mail>
* The issue tracker (GitHub): <https://github.com/gpc/grails-asynchronous-mail/issues>

Installation
------------

To install just add the plugin to the plugins block of `build.gradle`. For Grails 3.3.x
To install just add the plugin to the plugins block of `build.gradle`:

For Grails 5.x.x
```groovy
implementation "io.github.gpc:asynchronous-mail:3.1.2"
```

For grails 4.0.x
```groovy
compile "io.github.gpc:asynchronous-mail:3.0.0"
```

For Grails 3.3.x
```groovy
compile "org.grails.plugins:asynchronous-mail:2.0.2"
```

For Grails 3.2.11 and earlier

```groovy
compile "org.grails.plugins:asynchronous-mail:2.0.2-3.2.x"
```
Expand All @@ -52,12 +60,12 @@ asynchronous.mail.send.immediately=true
asynchronous.mail.clear.after.sent=false
asynchronous.mail.disable=false
asynchronous.mail.useFlushOnSave=true
asynchronous.mail.persistence.provider='hibernate4' // Possible values are 'hibernate', 'hibernate4', 'mongodb'
asynchronous.mail.persistence.provider='hibernate5' // Possible values are 'hibernate', 'hibernate4', 'hibernate5', 'mongodb'
asynchronous.mail.newSessionOnImmediateSend=false
asynchronous.mail.taskPoolSize=1
```

If you want to change this options just add options which you want to change to your configuration file `/grails-app/conf/application.groovy`.
If you want to change this options just add options which you want to change to your configuration file `/grails-app/conf/application.groovy` or `/grails-app/conf/application.yml`.

|Option|Default|Description|
|------|-------|-----------|
Expand All @@ -70,16 +78,16 @@ If you want to change this options just add options which you want to change to
|`asynchronous.mail.clear.after.sent`|`false`|If `true` then all messages will be deleted after sent. If `attachments` then attachments of all messages will be deleted.|
|`asynchronous.mail.disable`|`false`|If true then jobs aren't started.|
|`asynchronous.mail.useFlushOnSave`|`true`|By default the plugin flushes all changes to the DB on every step of the sending process for prevent resending but it makes overhead. So you can set this property to `false` and it will have better performance but will not have guarantee of prevention of resending.|
|`asynchronous.mail.persistence.provider`|`hibernate4`|The persistence provider. Possible values are `hibernate`, `hibernate3`, `hibernate4`, `hibernate5`, `mongodb`.|
|`asynchronous.mail.persistence.provider`|`hibernate5`|The persistence provider. Possible values are `hibernate`, `hibernate3`, `hibernate4`, `hibernate5`, `mongodb`.|
|`asynchronous.mail.newSessionOnImmediateSend`|`false`|If `true` the new DB session will be created for storing a message into DB. It's needed if you want to send an email in case of error when all changes in DB are rolled back.|
|`asynchronous.mail.taskPoolSize`|`1`|Max count of parallel tasks for sending messages concurrently.|

Configure the [mail](https://grails.org/plugins.html#plugin/mail) plugin. The Asynchronous Mail plugin uses the [mail](https://grails.org/plugins.html#plugin/mail) plugin for sending messages to the SMTP server.
Configure the [mail](https://plugins.grails.org/plugin/grails/mail) plugin. The Asynchronous Mail plugin uses the [mail](https://plugins.grails.org/plugin/grails/mail) plugin for sending messages to the SMTP server.

Usage
-----

If you already used the [mail](https://grails.org/plugins.html#plugin/mail) plugin, you have to import class `AsynchronousMailService` to your class.
If you already used the [mail](https://plugins.grails.org/plugin/grails/mail) plugin, you have to import class `AsynchronousMailService` to your class.

```groovy
import grails.plugin.asyncmail.AsynchronousMailService
Expand All @@ -105,22 +113,22 @@ Next, change your sendMail call.
asyncMailService.sendMail {
// Mail parameters
to 'john.smith@example.com'
subject 'Test';
html '<body><u>Test</u></body>';
attachBytes 'test.txt', 'text/plain', byteBuffer;
subject 'Test'
html '<body><u>Test</u></body>'
attachBytes 'test.txt', 'text/plain', byteBuffer

// Additional asynchronous parameters (optional)
beginDate new Date(System.currentTimeMillis()+60000) // Starts after one minute, default current date
endDate new Date(System.currentTimeMillis()+3600000) // Must be sent in one hour, default infinity
maxAttemptsCount 3; // Max 3 attempts to send, default 1
attemptInterval 300000; // Minimum five minutes between attempts, default 300000 ms
delete true; // Marks the message for deleting after sent
immediate true; // Run the send job after the message was created
priority 10; // If priority is greater then message will be sent faster
maxAttemptsCount 3 // Max 3 attempts to send, default 1
attemptInterval 300000 // Minimum five minutes between attempts, default 300000 ms
delete true // Marks the message for deleting after sent
immediate true // Run the send job after the message was created
priority 10 // If priority is greater then message will be sent faster
}
```

Also see the sample application at <https://github.com/kefirfromperm/grails-asynchronous-mail-sample>.
Also see the sample application at <https://github.com/kefirfromperm/grails-asynchronous-mail-sample> (Grails 3).

The AsynchronousMailController and views
----------------------------------------
Expand All @@ -136,45 +144,31 @@ Logging

To enable full logging for the plugin just add the following lines to `/grails-app/conf/logback.groovy`.
```groovy
...
//...
// Enable Asynchronous Mail plugin logging
logger('grails.app.jobs.grails.plugin.asyncmail', TRACE, ['STDOUT'])
logger('grails.app.services.grails.plugin.asyncmail', TRACE, ['STDOUT'])
logger('grails.plugin.asyncmail', TRACE, ['STDOUT'])

// Enable Quartz plugin logging
logger('grails.plugins.quartz', DEBUG, ['STDOUT'])
...
//...
```

Indexes
-------

I recommend to create an index on the `async_mail_mess.status` column. It's result of my heuristic observations. Only DBA have to create indexes anyway.
A recommendation is to create an index on the `async_mail_mess.status` column. It's result of my heuristic observations. Only DBA have to create indexes anyway.

Issue tracking
--------------

You can report bugs on [GitHub](https://github.com/kefirfromperm/grails-asynchronous-mail/issues?state=open).
You also can ask me questions by email [kefirfromperm@gmail.com](mailto:kefirfromperm@gmail.com).
You can report bugs on [GitHub](https://github.com/gpc/grails-asynchronous-mail/issues?state=open).
You also can ask questions in the [Grails Community Slack Channels](https://slack.grails.org/).
Please enable logs and attach them to your issue.

Please review this project at [OpenHUB](https://www.openhub.net/p/grails-asynchronous-mail).

Contribution
------------

If you want to contribute to the plugin just open a pull request to the repository
<https://github.com/kefirfromperm/grails-asynchronous-mail>.

Unit tests are very very sweet things. They help us to find bugs and to modify code without adding new bugs. It's very
interesting to see how they work. I like to see how they work. What is better than unit tests? More unit tests!
Unit tests are good!

And comments... Comments are good also. They are not as good as unit tests but they are definitely good. If you known
Chinese or Arabic it's good. Seriously. It's awesome! But I don't speak them. So write comments in English.

Donation
--------

If you want to give me a beer just send some money to <https://www.paypal.me/kefir>
<https://github.com/gpc/grails-asynchronous-mail>.
Loading