Created
August 14, 2014 16:08
-
-
Save todvora/379d7e69bf353a8776bf to your computer and use it in GitHub Desktop.
Mailgun Java Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Response SendSimpleMessage() { | |
Client client = ClientBuilder.newClient(); | |
client.register(HttpAuthenticationFeature.basic("api", "key-################################")); | |
WebTarget target = client.target("https://api.mailgun.net/v2/sandbox################################.mailgun.org/messages"); | |
MultivaluedMapImpl formData = new MultivaluedMapImpl(); | |
formData.add("from", "Mailgun Sandbox <postmaster@sandbox################################.mailgun.org>"); | |
formData.add("to", "Tomas Dvorak <todvora@gmail.com>"); | |
formData.add("subject", "Hello Tomas Dvorak"); | |
formData.add("text", "Congratulations Tomas Dvorak, you just sent an email with Mailgun! You are truly awesome! You can see a record of this email in your logs: https://mailgun.com/cp/log . You can send up to 300 emails/day from this sandbox server. Next, you should add your own domain so you can send 10,000 emails/month for free."); | |
return target.request(MediaType.APPLICATION_FORM_URLENCODED).post(Entity.form(formData)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment