{"id":18783948,"url":"https://github.com/sparkpost/java-sparkpost","last_synced_at":"2025-04-13T12:27:18.119Z","repository":{"id":28473406,"uuid":"31989343","full_name":"SparkPost/java-sparkpost","owner":"SparkPost","description":"SparkPost client library for Java","archived":false,"fork":false,"pushed_at":"2023-08-23T05:29:00.000Z","size":674,"stargazers_count":39,"open_issues_count":30,"forks_count":35,"subscribers_count":62,"default_branch":"master","last_synced_at":"2025-04-13T12:27:11.076Z","etag":null,"topics":["client-library","email","java"],"latest_commit_sha":null,"homepage":"https://www.sparkpost.com/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SparkPost.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-03-11T00:23:31.000Z","updated_at":"2024-04-16T22:52:58.000Z","dependencies_parsed_at":"2024-11-07T20:44:00.455Z","dependency_job_id":"83f2ba87-fa89-4fcb-bed8-05ef273723f0","html_url":"https://github.com/SparkPost/java-sparkpost","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SparkPost%2Fjava-sparkpost","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SparkPost%2Fjava-sparkpost/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SparkPost%2Fjava-sparkpost/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SparkPost%2Fjava-sparkpost/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SparkPost","download_url":"https://codeload.github.com/SparkPost/java-sparkpost/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248713399,"owners_count":21149678,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client-library","email","java"],"created_at":"2024-11-07T20:41:15.466Z","updated_at":"2025-04-13T12:27:18.081Z","avatar_url":"https://github.com/SparkPost.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"https://www.sparkpost.com\"\u003e\u003cimg src=\"https://www.sparkpost.com/sites/default/files/attachments/SparkPost_Logo_2-Color_Gray-Orange_RGB.svg\" width=\"200px\"/\u003e\u003c/a\u003e\n\n[Sign up](https://app.sparkpost.com/join?plan=free-0817?src=Social%20Media\u0026sfdcid=70160000000pqBb\u0026pc=GitHubSignUp\u0026utm_source=github\u0026utm_medium=social-media\u0026utm_campaign=github\u0026utm_content=sign-up) for a SparkPost account and visit our [Developer Hub](https://developers.sparkpost.com) for even more content.\n\n# SparkPost Java Library\n\n[![Build Status](https://travis-ci.org/SparkPost/java-sparkpost.svg?branch=master)](https://travis-ci.org/SparkPost/java-sparkpost) [![Slack Status](http://slack.sparkpost.com/badge.svg)](http://slack.sparkpost.com)\n\nUse this library in Java applications to easily access the SparkPost Email API in your application.\n\n## Version Compatibility Note\n\n### Version 0.6.2 -\u003e 0.6.3\n\nDue to [issue 57](https://github.com/SparkPost/java-sparkpost/issues/57) and to maintain compatibility with old and new version of Apache HTTP Client `SPARKPOST_BASE_URL` must not end with a `/` slash.\n\n### Version 0.12 -\u003e 0.13\n\nAlthough we try to maintain library backward compatibility this migration may require some minor changes to your code. Substitution data was changed from `Map\u003cString, String\u003e` to `Map\u003cString, Object\u003e`. Most client code will just need to change their map to this new signature.\n\n## Getting Started\n\nThe SparkPost Java Library is available in this [Maven Repository](https://repo.maven.apache.org/maven2/com/sparkpost/sparkpost-lib) or in GitHub [Releases](https://github.com/SparkPost/java-sparkpost/releases).\n\n\n```xml\n\u003cdependency\u003e\n\t\u003cgroupId\u003ecom.sparkpost\u003c/groupId\u003e\n\t\u003cartifactId\u003esparkpost-lib\u003c/artifactId\u003e\n\t\u003cversion\u003e0.27\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Building SparkPost4J\n\n## Basic Send Email Example\n\n```java\n\npackage com.sparkpost;\n\nimport com.sparkpost.exception.SparkPostException;\n\npublic class SparkPost {\n\n    public static void main(String[] args) throws SparkPostException {\n        String API_KEY = \"YOUR API KEY HERE!!!\";\n        Client client = new Client(API_KEY);\n\n        client.sendMessage(\n                \"you@yourdomain.com\",\n                \"to@sparkpost.com\",\n                \"The subject of the message\",\n                \"The text part of the email\",\n                \"\u003cb\u003eThe HTML part of the email\u003c/b\u003e\");\n\n    }\n}\n\n```\n\n## Basic Send Email through SparkPost EU \n\n```java\n\n\npackage com.sparkpost;\n\nimport com.sparkpost.exception.SparkPostException;\nimport com.sparkpost.transport.IRestConnection;\n\npublic class SparkPost {\n\n    public static void main(String[] args) throws SparkPostException {\n        String API_KEY = \"YOUR API KEY HERE!!!\";\n\n        // To use the SparkPost EU use the IRestConnection.SPC_EU_ENDPOINT endpoint\n        Client client = new Client(API_KEY, IRestConnection.SPC_EU_ENDPOINT);\n\n        client.sendMessage(\n                \"you@yourdomain.com\",\n                \"to@sparkpost.com\",\n                \"The subject of the message\",\n                \"The text part of the email\",\n                \"\u003cb\u003eThe HTML part of the email\u003c/b\u003e\");\n\n    }\n}\n\n```\n\n\n\n## Advanced Send Email Example\n\nWith SparkPost you have complete control over all aspects of an email and a powerful templating solution.\n\n```java\n\nprivate void sendEmail(String from, String[] recipients, String email) throws SparkPostException {\n\tTransmissionWithRecipientArray transmission = new TransmissionWithRecipientArray();\n\n\t// Populate Recipients\n\tList\u003cRecipientAttributes\u003e recipientArray = new ArrayList\u003cRecipientAttributes\u003e();\n\tfor (String recipient : recipients) {\n\tRecipientAttributes recipientAttribs = new RecipientAttributes();\n\t\trecipientAttribs.setAddress(new AddressAttributes(recipient));\n\t\trecipientArray.add(recipientAttribs);\n\t}\n\ttransmission.setRecipientArray(recipientArray);\n\n\t // Populate Substitution Data\n    Map\u003cString, Object\u003e substitutionData = new HashMap\u003cString, Object\u003e();\n    substitutionData.put(\"yourContent\", \"You can add substitution data too.\");\n    transmission.setSubstitutionData(substitutionData);\n\n    // Populate Email Body\n    TemplateContentAttributes contentAttributes = new TemplateContentAttributes();\n    contentAttributes.setFrom(new AddressAttributes(from));\n    contentAttributes.setSubject(\"Your subject content here. {{yourContent}}\");\n    contentAttributes.setText(\"Your Text content here.  {{yourContent}}\");\n    contentAttributes.setHtml(\"\u003cp\u003eYour \u003cb\u003eHTML\u003c/b\u003e content here.  {{yourContent}}\u003c/p\u003e\");\n    transmission.setContentAttributes(contentAttributes);\n\n\t// Send the Email\n\tRestConnection connection = new RestConnection(client, getEndPoint());\n\tResponse response = ResourceTransmissions.create(connection, 0, transmission);\n\n\tlogger.debug(\"Transmission Response: \" + response);\n}\n\n```\n\n## Running The Sample Apps\n\nThe sample apps are held in `apps/sparkpost-samples-app` with each sample's source code in `apps/sparkpost-samples-app/src/main/java/com/sparkpost/samples/`.\n\nTo build the samples:\n\n```bash\ncd apps/sparkpost-samples-app\nmvn compile\n```\n\nOne the samples are built, create `config.properties` by copying `apps/sparkpost-samples-app/config.properties.example` and filling in your SparkPost API key and other test parameters.\n\nYou can now run your chosen sample through maven:\n\n```bash\nmvn exec:java -Dexec.mainClass=com.sparkpost.samples.SendEmailCCSample\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsparkpost%2Fjava-sparkpost","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsparkpost%2Fjava-sparkpost","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsparkpost%2Fjava-sparkpost/lists"}