Skip to content

Commit

Permalink
🐛 更换demo邮箱地址,修复邮箱不能使用问题
Browse files Browse the repository at this point in the history
  • Loading branch information
xkcoding committed Aug 27, 2019
1 parent ab642de commit 9624ed3
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
5 changes: 3 additions & 2 deletions spring-boot-demo-email/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ spring:
host: smtp.mxhichina.com
port: 465
username: [email protected]
# 使用 jasypt 加密密码
password: ENC(6XYNBOJrcmAOiNqZiVaqw/ff8rjusN2H)
# 使用 jasypt 加密密码,使用com.xkcoding.email.PasswordTest.testGeneratePassword 生成加密密码,替换 ENC(加密密码)
password: ENC(OT0qGOpXrr1Iog1W+fjOiIDCJdBjHyhy)
protocol: smtp
test-connection: true
default-encoding: UTF-8
Expand All @@ -98,6 +98,7 @@ spring:
jasypt:
encryptor:
password: spring-boot-demo

```

## MailService.java
Expand Down
4 changes: 2 additions & 2 deletions spring-boot-demo-email/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ spring:
host: smtp.mxhichina.com
port: 465
username: [email protected]
# 使用 jasypt 加密密码
password: ENC(6XYNBOJrcmAOiNqZiVaqw/ff8rjusN2H)
# 使用 jasypt 加密密码,使用com.xkcoding.email.PasswordTest.testGeneratePassword 生成加密密码,替换 ENC(加密密码)
password: ENC(OT0qGOpXrr1Iog1W+fjOiIDCJdBjHyhy)
protocol: smtp
test-connection: true
default-encoding: UTF-8
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.xkcoding.email;

import org.jasypt.encryption.StringEncryptor;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

/**
* <p>
* 数据库密码测试
* </p>
*
* @author yangkai.shen
* @date Created in 2019/8/27 16:15
*/
public class PasswordTest extends SpringBootDemoEmailApplicationTests {
@Autowired
private StringEncryptor encryptor;

/**
* 生成加密密码
*/
@Test
public void testGeneratePassword() {
// 你的邮箱密码
String password = "Just4Test!";
// 加密后的密码(注意:配置上去的时候需要加 ENC(加密密码))
String encryptPassword = encryptor.encrypt(password);
String decryptPassword = encryptor.decrypt(encryptPassword);

System.out.println("password = " + password);
System.out.println("encryptPassword = " + encryptPassword);
System.out.println("decryptPassword = " + decryptPassword);
}
}

0 comments on commit 9624ed3

Please sign in to comment.