A. Turn the QQ-mail service
(1) landing QQ find the settings, click account
(2) pull down, open the POP3 / SMTP services and IMAP / SMTP services
When the open IMAP / SMTP there will be a string of cipher text, save it to use later
Two .spring boot configuration mail service
Add the following configuration in the configuration file application.yml spring boot in
1 spring: 2 mail: 3 username: 1963342385@qq.com 4 password: yqc...fchj 5 host: smtp.qq.com
password is the time to open mail services resulting ciphertext password
III. Coding
Test code
1 @RunWith(SpringRunner.class) 2 @SpringBootTest 3 public class ExchangeOfLearningPlatformApplicationTests { 4 @Autowired 5 JavaMailSenderImpl mailSender; 6 private String emailServiceCode; 7 8 public void test(){ 9 emailServiceCode = "1234"; 10 SimpleMailMessage message = new SimpleMailMessage(); 11 message.setSubject("注册验证码"); 12 message.setText("注册验证码是:" + emailServiceCode); 13 message.setFrom("[email protected]"); 14 mailSender.send(message); 15 } 16 }
Code Description:
Create a simple message object: SimpleMailMessage message = new SimpleMailMessage ();Set the message header: message.setSubject ( );
Set file contents: message.setText ( );
Set Write-mail: message.setFrom ( );
sending mail: mailSender.send (the Message);
A. Turn the QQ-mail service
(1) landing QQ find the settings, click account
(2) pull down, open the POP3 / SMTP services and IMAP / SMTP services
When the open IMAP / SMTP there will be a string of cipher text, save it to use later
Two .spring boot configuration mail service
Add the following configuration in the configuration file application.yml spring boot in
1 spring: 2 mail: 3 username: 1963342385@qq.com 4 password: yqc...fchj 5 host: smtp.qq.com
password is the time to open mail services resulting ciphertext password
III. Coding
Test code
1 @RunWith(SpringRunner.class) 2 @SpringBootTest 3 public class ExchangeOfLearningPlatformApplicationTests { 4 @Autowired 5 JavaMailSenderImpl mailSender; 6 private String emailServiceCode; 7 8 public void test(){ 9 emailServiceCode = "1234"; 10 SimpleMailMessage message = new SimpleMailMessage(); 11 message.setSubject("注册验证码"); 12 message.setText("注册验证码是:" + emailServiceCode); 13 message.setFrom("[email protected]"); 14 mailSender.send(message); 15 } 16 }
Code Description:
Create a simple message object: SimpleMailMessage message = new SimpleMailMessage ();Set the message header: message.setSubject ( );
Set file contents: message.setText ( );
Set Write-mail: message.setFrom ( );
sending mail: mailSender.send (the Message);