forked from grails-aws/grails-aws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAwsSesSendPingMail.groovy
39 lines (30 loc) · 1.89 KB
/
AwsSesSendPingMail.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import com.amazonaws.auth.BasicAWSCredentials
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient
import com.amazonaws.services.simpleemail.model.Body
import com.amazonaws.services.simpleemail.model.Content
import com.amazonaws.services.simpleemail.model.Message
import com.amazonaws.services.simpleemail.model.Destination
import com.amazonaws.services.simpleemail.model.SendEmailResult
import com.amazonaws.services.simpleemail.model.SendEmailRequest
includeTargets << grailsScript("Init")
includeTargets << new File("${awsPluginDir}/scripts/_ReadAwsCredentials.groovy")
target(main: "Send test e-mail, so user can check if e-mail is verified and working") {
println """************************************************************
* Attention: If you only subscribed to Amazon SES and *
* still didn't get access for production using, you'll *
* only be allowed to send e-mails 'from' AND 'to' emais *
* that has been verified with amazon. *
* So, you'll have to use the 'grails aws-ses-verify-email' *
* for both sender and recipient adresses. After getting *
* production access, this won't be needed. *
************************************************************"""
depends (readAwsCredentials)
def credentials = new BasicAWSCredentials(accessKey, secretKey)
def ses = new AmazonSimpleEmailServiceClient(credentials)
ant.input(message: "Enter the sender e-mail [has to be verified]: ", addproperty: "senderEmail")
ant.input(message: "Enter the e-mail address to recieve ping message: ", addproperty: "recipientEmail")
def message = new Message(new Content("[Grails AWS Plugin] Ping e-mail"), new Body(new Content("Test ok!")))
def result = ses.sendEmail(new SendEmailRequest(senderEmail, new Destination().withToAddresses(recipientEmail), message))
println "[AWS SES] E-mail queued. Id: ${result.getMessageId()}"
}
setDefaultTarget(main)