user2206724
user2206724

Reputation: 1365

RestClient::ResourceNotFound (404 Resource Not Found):

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?

Upvotes: 5

Views: 6007

Answers (1)

Erick Eduardo Garcia
Erick Eduardo Garcia

Reputation: 1157

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.

Upvotes: 4

Related Questions