Reputation: 9032
I want to send a mail via Groovy. I tried with the mail
command in mac and its working fine.
This is the command I'm using :
echo $message | mail -s "subject" [email protected]
Where message
is a gstring :
def message = """ Hi
Test mail """
The problem I'm facing is; when the mail is delivered the message
is coming in a single line rather than the way it stored.
Where I'm making the mistake??
Upvotes: 0
Views: 156
Reputation: 171094
You can do:
[ '/bin/bash', '-c', "echo '$msg' | mail -s 'subject' [email protected]" ].execute().waitFor()
ie: wrap the msg
in quotes '
Obviously, any quotes in msg
will need to be escaped, or this will fail.
A more resilient option would be to use java mail
Upvotes: 1