DEBUG: JavaMail version 1.6.1
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Oracle], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Oracle], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Oracle]}
DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Oracle], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Oracle], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Oracle], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]}
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]
DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "smtp.163.com", port 465, isSSL false
DEBUG SMTP: EOF: [EOF]
DEBUG SMTP: could not connect to host "smtp.163.com", port: 465, response: -1
2021-06-02 16:35:42.323 ERROR 11141 --- [nio-8999-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Could not connect to SMTP host: smtp.163.com, port: 465, response: -1. Failed messages: javax.mail.MessagingException: Could not connect to SMTP host: smtp.163.com, port: 465, response: -1; message exceptions (1) are:
Failed message 1: javax.mail.MessagingException: Could not connect to SMTP host: smtp.163.com, port: 465, response: -1] with root cause
javax.mail.MessagingException: Could not connect to SMTP host: smtp.163.com, port: 465, response: -1
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2197) ~[javax.mail-1.6.1.jar:1.6.1]
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:740) ~[javax.mail-1.6.1.jar:1.6.1]
at javax.mail.Service.connect(Service.java:366) ~[javax.mail-1.6.1.jar:1.6.1]
at org.springframework.mail.javamail.JavaMailSenderImpl.connectTransport(JavaMailSenderImpl.java:515) ~[spring-context-support-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:435) ~[spring-context-support-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:321) ~[spring-context-support-5.0.8.RELEASE.jar:5.0.8.RELEASE]
spring:
mail:
host: smtp.163.com
username: cocoococ@163.com
password: ajhdasdkaklsjdl
port: 465
default-encoding: UTF-8
properties:
mail:
smtp:
socketFactoryClass: javax.net.ssl.SSLSocketFactory
debug: true
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
@RestController
@RequestMapping("test")
public class TestController {
@Autowired
JavaMailSender javaMailSender;
@GetMapping("sendMail")
public void sendMail(){
SimpleMailMessage message = new SimpleMailMessage();
message.setSubject("这是一封测试邮件");
message.setFrom("cocoococ@163.com");
message.setTo("222qwioqin@qq.com");
message.setSentDate(new Date());
message.setText("这是测试邮件的正文");
javaMailSender.send(message);
可疑点在于上面红线位置
- 我明明设置了账号、授权码登录,但是useAuth还是false
- isSsl 也是false
从报错堆栈中找到
com.sun.mail.smtp.SMTPTransport#protocolConnect
就是说 useAuth 其实是从属性中解析的,这里的name代表协议类型(smtp、pop3)
那么完整的属性名应该是 mail.smtp.auth
接着
com.sun.mail.smtp.SMTPTransport#openServer(java.lang.String, int)
这里的isSSL
是成员属性
根据调试只有在构造函数中才会赋值
com.sun.mail.smtp.SMTPTransport#SMTPTransport(javax.mail.Session, javax.mail.URLName, java.lang.String, boolean)
那么完整的属性名应该是 mail.smtp.ssl.enable
所以只要修改yml文件即可
spring:
mail:
host: smtp.163.com
username: cocoococ@163.com
password: ajhdasdkaklsjdl
port: 465
default-encoding: UTF-8
properties:
mail:
smtp:
starttls:
enable: true
auth: true
ssl:
enable: true
socketFactoryClass: javax.net.ssl.SSLSocketFactory
debug: true
server:
port: 8999
servlet:
path: /mall
问题描述DEBUG: JavaMail version 1.6.1DEBUG: successfully loaded resource: /META-INF/javamail.default.providersDEBUG: Tables of loaded providersDEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,co
org.springframework.mail.MailSendException: Failed messages: com.sun.mail.smtp.SMTPSendFailedExcepti
最近学习了一下javax.mail,想通过gmail邮箱发送邮件到qq邮箱。但是由于gmail的两步验证,一直授权无法通过。
错误如下:DEBUG: JavaMail version 1.4.7
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded prov
解决:trying to connect to host "smtp.qq.com", port 465, isSSL true
javax.mail.MessagingException: Could not connect to SMTP host: smtp.qq.com, port: 465;
nested exception is:
最近遇到一个诡异的发送邮件的问题,特记录之。
现有代码中已有 EmailUtils 类,并提供了static方法 sendEmail() ,在多个模块中被调用,一直运行良好。
现在要在另一个模块里添加发送邮件功能。把代码copy过来,稍微修改一下title,content,sender之类的参数,代码基本上大同小异。在本机测试一下 main() 方法,工作OK。然而,当我本地起server运行的时候(Java web project),却发现没有收到mail。
我在调用 sendEmail()
使用spring mail发送邮件的时候报以下异常:
2019-06-11 15:35:11.746 [http-nio-8090-exec-4] INFO c.i.bbm.shiro.session.RedisShiroSessionRepository - session过期时间:3600000
2019-06-11 15:35:11.926 [http-nio-8090-exec-4] E...
邮件为什么会被退回经常上网发送邮件的人可能会有邮件被退回的经历,收到被退回的邮件要具体分析,退回的信件一般都会有简短的说明,结合这些说明你可以进一步了解具体的退信原因并作出相应处理。
一、退信由哪些内容组成由于...
Maven 依赖 <!-- javaemail -->
<javaemail.version>1.4.5</javaemail.version>
<mail.version>1.4.1</mail.version> <!-- javamail 发送邮件-->
<dependency>
<groupId>jav
**在网络中实现邮件发送和接收的功能,就必须要有专门的邮件服务器(使用**SMTP协议**),我们发送一封邮件,先要经过各层路由,交换机,基站,然后存到该邮件服务器,(不同的邮件有不同的邮件服务器,比如网易的邮箱服务器,QQ的邮箱服务器),然后发送的邮箱服务器(使用**POP3协议**)又通过基站发送到对应的服务器中,这个时候作为收件人会有邮件到达的提醒,在你打开邮件的过程就是从邮件服务器中读取数据的过程。
SMTP服务器地址:一般是smtp.xxx.com,比如smtp.163.com,sm
缺少如下配置
spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
jdk1.8版本太高删除(C:\Program Files\Java\jdk1.8.0_291\jre\lib\security\java.security)的SSLv3, TLSv1, TLSv1.1
你可以使用 Spring Boot 的邮件发送功能来发送电子邮件。首先,你需要在项目的依赖中添加 Spring Boot 的邮件依赖。在 `pom.xml` 文件中添加以下代码:
```xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
接下来,你需要在配置文件中配置邮件相关的属性。在 `application.properties`(或 `application.yml`)文件中添加以下属性:
```properties
# 邮件服务器主机名
spring.mail.host=your-mail-host
# 邮件服务器端口
spring.mail.port=your-mail-port
# 邮件发送者用户名
spring.mail.username=your-username
# 邮件发送者密码
spring.mail.password=your-password
# 邮件发送者地址
spring.mail.from=your-email-address
现在,你可以在你的代码中使用 `JavaMailSender` 接口来发送邮件。你可以注入 `JavaMailSender` 接口的实例,并使用 `send()` 方法发送邮件。以下是一个简单的示例:
```java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;
@Service
public class EmailService {
@Autowired
private JavaMailSender javaMailSender;
public void sendEmail(String to, String subject, String text) {
SimpleMailMessage message = new SimpleMailMessage();
message.setTo(to);
message.setSubject(subject);
message.setText(text);
javaMailSender.send(message);
你可以在需要发送邮件的地方调用 `sendEmail()` 方法,并传入收件人地址、邮件主题和邮件内容。
这是使用 Spring Boot 发送邮件的基本步骤。你可以根据自己的需求进行进一步的定制和配置。
MybatisPlusExcepection: can not find lambda cache for this property [XX] for entity [xxx]
11031
MybatisPlusExcepection: can not find lambda cache for this property [XX] for entity [xxx]
spring 运行时替换 单例bean 实现
帆影匆匆:
Mybatis-plus 多表联查实现(非手写sql)
攻城狮狮:
微信内置浏览器校验限制绕过
weixin_45194928: