forked from vert-x3/vertx-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMailEB.java
40 lines (32 loc) · 1.04 KB
/
MailEB.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package io.vertx.example.mail;
import io.vertx.core.AbstractVerticle;
import io.vertx.example.util.Runner;
import io.vertx.ext.mail.MailMessage;
import io.vertx.ext.mail.MailService;
/**
* send a mail via event bus to the mail service running on another machine
*
* @author <a href="http://oss.lehmann.cx/">Alexander Lehmann</a>
*
*/
public class MailEB extends AbstractVerticle {
// Convenience method so you can run it in your IDE
public static void main(String[] args) {
Runner.runExample(MailEB.class);
}
public void start() {
MailService mailService = MailService.createEventBusProxy(vertx, "vertx.mail");
MailMessage email = new MailMessage()
.setBounceAddress("[email protected]")
.setTo("[email protected]")
.setSubject("this message has no content at all");
mailService.sendMail(email, result -> {
if (result.succeeded()) {
System.out.println(result.result());
} else {
System.out.println("got exception");
result.cause().printStackTrace();
}
});
}
}