javamail发邮件使用ssl
2018-03-30 16:58
387 查看
ssl 端口465
使用spring boot 架构
在yml文件中添加配置
javaMailProperties:
mail.smtp.ssl.enable: true
注意 :配置文件属性为javaMailProperties中添加mail.smtp.ssl.enable: true
StmpTransport 构造方法根据properties 变量中设置的mail.smtp.ssl.enable 来初始化isSSL属性为true
使用spring boot 架构
在yml文件中添加配置
javaMailProperties:
mail.smtp.ssl.enable: true
注意 :配置文件属性为javaMailProperties中添加mail.smtp.ssl.enable: true
StmpTransport 构造方法根据properties 变量中设置的mail.smtp.ssl.enable 来初始化isSSL属性为true
protected SMTPTransport(Session session, URLName urlname, String name, boolean isSSL) { super(session, urlname); logger = new MailLogger(this.getClass(), "DEBUG SMTP", session); traceLogger = logger.getSubLogger("protocol", null); noauthdebug = !PropUtil.getBooleanSessionProperty(session, "mail.debug.auth", false); if (urlname != null) name = urlname.getProtocol(); this.name = name; **if (!isSSL) isSSL = PropUtil.getBooleanSessionProperty(session, "mail." + name + ".ssl.enable", false); if (isSSL) this.defaultPort = 465; else this.defaultPort = 25;** this.isSSL = isSSL; // setting mail.smtp.quitwait to false causes us to not wait for the // response from the QUIT command quitWait = PropUtil.getBooleanSessionProperty(session, "mail." + name + ".quitwait", true); // mail.smtp.reportsuccess causes us to throw an exception on success reportSuccess = PropUtil.getBooleanSessionProperty(session, "mail." + name + ".reportsuccess", false); // mail.smtp.starttls.enable enables use of STARTTLS command useStartTLS = PropUtil.getBooleanSessionProperty(session, "mail." + name + ".starttls.enable", false); // mail.smtp.starttls.required requires use of STARTTLS command requireStartTLS = PropUtil.getBooleanSessionProperty(session, "mail." + name + ".starttls.required", false); // mail.smtp.userset causes us to use RSET instead of NOOP // for isConnected useRset = PropUtil.getBooleanSessionProperty(session, "mail." + name + ".userset", false); // mail.smtp.noop.strict requires 250 response to indicate success noopStrict = PropUtil.getBooleanSessionProperty(session, "mail." + name + ".noop.strict", true); // check if SASL is enabled enableSASL = PropUtil.getBooleanSessionProperty(session, "mail." + name + ".sasl.enable", false); if (enableSASL) logger.config("enable SASL"); useCanonicalHostName = PropUtil.getBooleanSessionProperty(session, "mail." + name + ".sasl.usecanonicalhostname", false); if (useCanonicalHostName) logger.config("use canonical host name"); // created here, because they're inner classes that reference "this" Authenticator[] a = new Authenticator[] { new LoginAuthenticator(), new PlainAuthenticator(), new DigestMD5Authenticator(), new NtlmAuthenticator(), new OAuth2Authenticator() }; StringBuffer sb = new StringBuffer(); for (int i = 0; i < a.length; i++) { authenticators.put(a[i].getMechanism(), a[i]); sb.append(a[i].getMechanism()).append(' '); } defaultAuthenticationMechanisms = sb.toString(); }
相关文章推荐
- JavaMail实现收发邮件(五)使用SSL实现加密传输
- JavaMail使用SSL遇到安全证书问题
- 使用JAVAMAIL发邮件的一个例子(转)
- Android 实现发邮件,使用JavaMail方式实现
- Javamail使用gmail发邮件
- javaMail使用qq邮箱报错: 530 Error: A secure connection is requiered(such as ssl)
- JavaMail给QQ邮箱发邮件报错,没有SSL加密
- 『JAVA基础』使用JavaMail发邮件的实例
- JavaMail使用SSL遇到安全证书问题
- JavaMail使用465端口发送SSL加密邮件
- 使用Apache Commons Mail 发邮件,用SSL方式
- javamail用QQ发邮件的时候报错SSl解决办法
- 使用JavaMail发送邮件,并使用465端口开启ssl加密传输,保证邮件安全
- javamail使用SSL加密方式465端口
- 『JAVA基础』使用JavaMail发邮件的实例 (转载)
- 收藏:JavaMail使用SSL遇到安全证书问题
- javaMail发邮件 简单小例子 解决QQ邮箱530 SSL问题
- JavaMail使用SSL的方式登录
- 使用JAVAMail发邮件DEMO
- 使用javamail报出:530 Error: A secure connection is requiered(such as ssl). More information at http://se