Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java sendgrid。SSL上的SMTP,或SMTP+;STARTTLS_Java_Email_Ssl_Sendgrid_Sendgrid Api V3 - Fatal编程技术网

Java sendgrid。SSL上的SMTP,或SMTP+;STARTTLS

Java sendgrid。SSL上的SMTP,或SMTP+;STARTTLS,java,email,ssl,sendgrid,sendgrid-api-v3,Java,Email,Ssl,Sendgrid,Sendgrid Api V3,我已经实现了以下电子邮件发送: Template template = freemarkerConfig.getTemplate(templateFileName); String html = FreeMarkerTemplateUtils.processTemplateIntoString(template, props); logger.debug("Send email to {} with subject: [{}]", Arrays.toString(to), subject); P

我已经实现了以下电子邮件发送:

Template template = freemarkerConfig.getTemplate(templateFileName);
String html = FreeMarkerTemplateUtils.processTemplateIntoString(template, props);
logger.debug("Send email to {} with subject: [{}]", Arrays.toString(to), subject);
Personalization personalization = new Personalization();
for (String toEmail : to) {
    personalization.addTo(new Email(toEmail));
}       
Mail mail = new Mail();
mail.addPersonalization(personalization);
mail.setSubject(subject);
mail.setFrom(new Email(from));
mail.addContent(new Content("text/html", html));
Request request = new Request();
try {
    request.setMethod(Method.POST);
    request.setEndpoint("mail/send");
    request.setBody(mail.build());
    Response response = this.sendGrid.api(request);
    logger.info("Response:{}", response);
    } catch (IOException ex) {
    logger.error("Exception occurred during email sending", ex);
}
我有一个要求,我需要使用
SMTP over SSL
,或者
SMTP+STARTTLS


我不知道这是什么意思。对于这种情况,我应该使用smtp api(而不是web api)吗?但是sendgrid官方网站建议使用web api。

如果您只关心通过TLS发送到sendgrid,只需确保您启动它并正确运行连接,它就会被加密发送

如果您需要确保所有邮件仅通过TLS从SendGrid发送出去,您可以选择发送邮件。SendGrid始终尝试TLS连接出站,但如果未设置该标志,则将恢复为未加密