I am trying to send mails using RestClient and mailgun.
I installed gem in my rails app and defined "require 'rest_client'" in config/application.rb.
Then to send mail, I wrote this in my message controller:
RestClient.post "https://api:key-3ax6xnjp29jd6fds4gc373sgvjxteol0" "@api.mailgun.net/v2/samples.mailgun.org/messages", :from => "Excited User <[email protected]>", :to => "[email protected], [email protected]", :subject => "Hello", :text => "Testing some Mailgun awesomness!"
I have created account with mailgun and used keys and url above as mentioned in my account.
When I run code, it gives error:
RestClient::ResourceNotFound (404 Resource Not Found):
Can anybody help me whats going wrong here?
You have to change this part "samples.mailgun.org" to a domain listed in your account info, there are mailgun subdomains and custom domains.
Assuming yo have a subdomain named sandbox0000.mailgun.org
#i prefer to join the strings
url = "https://api:[email protected]/v2/sandbox0000.mailgun.org/messages"
RestClient.post url, :from => "Excited User <[email protected]>", :to => "[email protected], [email protected]", :subject => "Hello", :text => "Testing some Mailgun awesomness!"
Your api key is a password to mailgun and you should not make it public.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With