代码拉取完成,页面将自动刷新
同步操作将从 githubsync/vertx-examples 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package io.vertx.example.mail;
import io.vertx.core.AbstractVerticle;
import io.vertx.example.util.Runner;
import io.vertx.ext.mail.MailAttachment;
import io.vertx.ext.mail.MailClient;
import io.vertx.ext.mail.MailConfig;
import io.vertx.ext.mail.MailMessage;
import java.util.ArrayList;
import java.util.List;
/**
* send a mail with HTML and inline images
*
* @author <a href="http://oss.lehmann.cx/">Alexander Lehmann</a>
*/
public class MailImages extends AbstractVerticle {
// Convenience method so you can run it in your IDE
public static void main(String[] args) {
Runner.runExample(MailImages.class);
}
@Override
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(2526);
MailClient mailClient = MailClient.createShared(vertx, new MailConfig().setPort(2526));
MailMessage email = new MailMessage()
.setFrom("user@example.com (Sender)")
.setTo("user@example.com (User Name)")
.setSubject("Test email")
.setText("full message is readable as html only")
.setHtml("visit vert.x <a href=\"http://vertx.io/\"><img src=\"cid:image1@example.com\"></a>");
MailAttachment attachment = MailAttachment.create()
.setData(vertx.fileSystem().readFileBlocking("logo-white-big.png"))
.setContentType("image/png")
.setName("logo-white-big.png")
.setDisposition("inline")
.addHeader("Content-ID", "<image1@example.com>");
List<MailAttachment> list = new ArrayList<>();
list.add(attachment);
email.setInlineAttachment(list);
mailClient.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();
}
});
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。