@@ -0,0 +1,2354 @@
+/*%0AMain.java%0A2014-09-24%0A%0ACopyright 2014 John Boyer%0A%0ALicensed under the Apache License, Version 2.0 (the %22License%22);%0Ayou may not use this file except in compliance with the License.%0AYou may obtain a copy of the License at%0A%0A    http://www.apache.org/licenses/LICENSE-2.0%0A%0AUnless required by applicable law or agreed to in writing, software%0Adistributed under the License is distributed on an %22AS IS%22 BASIS,%0AWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0ASee the License for the specific language governing permissions and%0Alimitations under the License.%0A*/%0Apackage com.rodaxsoft.mailgun.example;%0A%0Aimport javax.ws.rs.client.Client;%0Aimport javax.ws.rs.client.ClientBuilder;%0Aimport javax.ws.rs.client.Entity;%0Aimport javax.ws.rs.client.Invocation;%0Aimport javax.ws.rs.client.WebTarget;%0Aimport javax.ws.rs.core.Form;%0Aimport javax.ws.rs.core.MediaType;%0Aimport javax.ws.rs.core.Response;%0A%0Aimport org.apache.commons.logging.Log;%0Aimport org.apache.commons.logging.LogFactory;%0Aimport org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;%0A%0A/**%0A * Example Main class using the latest Jersey Client SDK 2.12%0A * @author John Boyer%0A *%0A */%0Apublic class Main %7B%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09Log log = LogFactory.getLog(Main.class);%0A%09%09%0A%09%09final Client client = ClientBuilder.newClient();%0A%09%09%0A%09%09HttpAuthenticationFeature authFeature;%0A%09%09authFeature = HttpAuthenticationFeature.%0A%09%09%09%09basicBuilder().%0A%09%09%09%09nonPreemptive().%0A%09%09%09%09credentials(%22api%22, %22key-3ax6xnjp29jd6fds4gc373sgvjxteol0%22).%0A%09%09%09%09build();%0A%09%09client.register(authFeature);%0A%0A%09%09WebTarget webTarget = client.%0A%09%09%09%09target(%22https://api.mailgun.net/v2/samples.mailgun.org%22).%0A%09%09%09%09path(%22messages%22);%0A%09%09%0A%09%09Form form = new Form();%0A%09%09form.param(%22to%22, %22john@example.com%22);%0A%09%09form.param(%22from%22, %22noreply@example.com%22);%0A%09%09form.param(%22subject%22, %22Hello World%22);%0A%09%09form.param(%22text%22, %22This is my first Mailgun email from Java%22);%0A%09%09//Set the Reply-TO header%0A%09%09form.param(%22h:Reply-To%22, %22support@example.com%22);%0A%09%09%0A%09%09Invocation.Builder invocationBuilder;%0A%09%09invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON_TYPE);%0A%09%09Response response = invocationBuilder.post(Entity.form(form));%0A%09%09int status = response.getStatus();%0A%09%09log.info(%22status = %22 + status);%0A%09%09%0A%09%09if(response.hasEntity()) %7B%0A%09%09%09String json = response.readEntity(String.class);%0A%09%09%09log.info(%22entity = %22 + json);%0A%09%09%7D%0A%09%7D%0A%0A%7D%0A

Create Main.java