public void start() { // Start a local STMP server, remove this line if you want to use your own server. // It just prints the sent message to the console LocalSmtpServer.start(2527); JsonObject config = new JsonObject(); config.put("port", 2527); config.put("address", "vertx.mail"); vertx.deployVerticle(MAIL_SERVICE_VERTICLE, new DeploymentOptions().setConfig(config), done -> { MailService mailService = MailService.createEventBusProxy(vertx, "vertx.mail"); MailMessage email = new MailMessage() .setBounceAddress("bounce@example.com") .setTo("user@example.com") .setSubject("this message has no content at all"); mailService.sendMail(email, result -> { if (result.succeeded()) { System.out.println(result.result()); System.out.println("Mail sent"); } else { System.out.println("got exception"); result.cause().printStackTrace(); } }); }); }
public static io.vertx.ext.mail.MailService sendMail(io.vertx.ext.mail.MailService j_receiver, java.util.Map<String, Object> email, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) { io.vertx.core.impl.ConversionHelper.fromObject(j_receiver.sendMail(email != null ? new io.vertx.ext.mail.MailMessage(io.vertx.core.impl.ConversionHelper.toJsonObject(email)) : null, resultHandler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.ext.mail.MailResult>>() { public void handle(io.vertx.core.AsyncResult<io.vertx.ext.mail.MailResult> ar) { resultHandler.handle(ar.map(event -> event != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(event.toJson()) : null)); } } : null)); return j_receiver; } }
@Test public void mailTest(TestContext testContext) { this.testContext=testContext; testSuccess(MailService.createEventBusProxy(vertx, "vertx.mail")); }
@Override public void stop() { if (service != null) { service.close(); } } }