I am using RestClient in my rails app to send emails. The following Curl command works:
curl -s "https://api:key-XYZ@api.mailgun.net/v2/sandbox30000.mailgun.org/messages" \
-F from='Mailgun Sandbox <postmaster@sandbox30000.mailgun.org>' \
-F to='me <my-email-id@gmail.com>'\
-F subject='Hello XYZ' \
-F text='Congratulations, you just sent an email with Mailgun! You are truly awesome!'
But when I try the same using RestClient, I get the following error message:
error response !!{
"message": "'from' parameter is missing"
}
error message !!400 Bad Request
RestClient call:
RestClient::Request.execute(
:url => "https://api:key-XYZ@api.mailgun.net/v2/sandbox0000.mailgun.org/messages",
:method => :post,
:from => 'Mailgun Sandbox <postmaster@sandbox30000.mailgun.org>',
:sender => 'Mailgun Sandbox <postmaster@sandbox30000.mailgun.org>',
:to => "my-email-id@gmail.com",
:subject => "Hello XYZ",
:text => "Text body",
:"h:X-My-Header" => "www/mailgun-email-send",
:verify_ssl => false)