I am trying to use MailGun Transactional Email Service through my RESTful API, but I cannot get it to work. I can send messages through SMTP, but I prefer to use their API.
Their documentation contains the following code:
public static ClientResponse SendSimpleMessage() { Client client = Client.create(); client.addFilter(new HTTPBasicAuthFilter("api", "key-*****")); WebResource webResource = client.resource("https://api.mailgun.net/v2/DOMAIN" + "/messages"); MultivaluedMapImpl formData = new MultivaluedMapImpl(); formData.add("from", "Excited User < mailgun@DOMAIN >"); formData.add("to", " bar@example.com "); formData.add("to", " bar@example.com "); formData.add("subject", "Hello"); formData.add("text", "Testing some Mailgun awesomness!"); return webResource.type(MediaType.APPLICATION_FORM_URLENCODED). post(ClientResponse.class, formData); }
Obviously, I need some kind of REST client to use this code, but I could not find anything on the Internet that works for me. Can someone please explain to me step by step how I do this work. I use Eclipse, JAVA EE, No Maven
java rest mailgun
user3586514
source share