////
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
////

The Grails Mail plugin provides a convenient DSL for _sending_ email. It supports plain-text, HTML, attachments, inline resources and i18n among other features.

Email can be sent using the `mailService` via the `sendMail` method. Here is an example:

[source,groovy]
----
mailService.sendMail {
   to 'fred@gmail.com', 'ginger@gmail.com'
   from 'john@gmail.com'
   cc 'marge@gmail.com', 'ed@gmail.com'
   bcc 'joe@gmail.com'
   subject 'Hello John'
   text 'Here is some text'
}
----

Here we are sending a plain-text email with no attachments to the given addresses. The `sendMail` method is injected into all Controllers and Services to simplify access:

[source,groovy]
----
sendMail {
   to 'fred@example.com'
   subject 'Hello Fred'
   text 'How are you?'
}
----

==== Installation

Add the plugin to the `dependencies` block of your `build.gradle`. The version is managed by the Grails BOM, so it does not need to be specified:

[source,groovy]
----
dependencies {
    implementation 'org.apache.grails:grails-mail'
}
----
