Java REST Mailgun

三世轮回 提交于 2019-12-04 04:27:33

I'm developing a Java mail library to easily send email messages using Mailgun. It may fit your needs.

https://github.com/sargue/mailgun

It allows you to send messages like this:

MailBuilder.using(configuration)
    .to("marty@mcfly.com")
    .subject("This is the subject")
    .text("Hello world!")
    .build()
    .send();

Even file attachments are easy:

MailBuilder.using(configuration)
    .to("marty@mcfly.com")
    .subject("This message has an text attachment")
    .text("Please find attached a file.")
    .multipart()
    .attachment(new File("/path/to/image.jpg"))
    .build()
    .send();

There is also support for asynchronous message sending and a HTML mail helper. It is a young project, feedback is very welcome.

You need the following dependencies:

You can download the JARs from mvnrepository and add them to your classpath.

Use the following dependencies if you should switch to Maven:

<dependency>
  <groupId>com.sun.jersey</groupId>
  <artifactId>jersey-core</artifactId>
  <version>1.19</version>
</dependency>
<dependency>
  <groupId>com.sun.jersey</groupId>
  <artifactId>jersey-client</artifactId>
  <version>1.19</version>
</dependency>
<dependency>
  <groupId>com.sun.jersey.contribs</groupId>
  <artifactId>jersey-multipart</artifactId>
  <version>1.19</version>
</dependency>
Hpsaturn

Maybe try with this post, using basic implementation of MailGun API with Retrofit library: send mail from android without using smtp and user interaction

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!