1.春・ブート・スターターメールの技術概要
1.1コンフィギュレーションは、タイプを読み取りますSMTPTransport
- 情報は、アプリケーションがこのクラスで見ることができるように構成する必要があり、あなたは、このようなブレークポイントで見ることができます
1.2。設定ファイル
spring.mail.host=smtp.163.com
spring.mail.username=15068610616@163.com
spring.mail.password=xxx
# 启动ssl
spring.mail.properties.mail.smtp.ssl.enable=true
# 启动tls
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
spring.mail.properties.mail.smtp.connectiontimeout=5000
spring.mail.properties.mail.smtp.timeout=3000
spring.mail.properties.mail.smtp.writetimeout=5000
1.3テストコード
@RunWith(SpringRunner.class)
@SpringBootTest
public class ZookeeperApplicationTests {
@Autowired
private JavaMailSender mailSender;
@Test
public void testMail() throws MessagingException {
MimeMessage mimeMessage = mailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
//发件人
helper.setFrom("[email protected]");
//收件人
helper.setTo("[email protected]");
//标题
helper.setSubject("subject");
//文本
helper.setText("message text");
//附件
helper.addAttachment("downFile",new File("D:\\cygwin64\\home\\workspace3\\learn-demo\\zookeeper\\src\\test\\java\\com\\tzxylao\\design\\ZookeeperApplicationTests.java"));
mailSender.send(mimeMessage);
}
}
オリジナル住所ます。https://www.cnblogs.com/sky-chen/p/10710516.html
1.春・ブート・スターターメールの技術概要
1.1コンフィギュレーションは、タイプを読み取りますSMTPTransport
- 情報は、アプリケーションがこのクラスで見ることができるように構成する必要があり、あなたは、このようなブレークポイントで見ることができます
1.2。設定ファイル
spring.mail.host=smtp.163.com
spring.mail.username=15068610616@163.com
spring.mail.password=xxx
# 启动ssl
spring.mail.properties.mail.smtp.ssl.enable=true
# 启动tls
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
spring.mail.properties.mail.smtp.connectiontimeout=5000
spring.mail.properties.mail.smtp.timeout=3000
spring.mail.properties.mail.smtp.writetimeout=5000
1.3テストコード
@RunWith(SpringRunner.class)
@SpringBootTest
public class ZookeeperApplicationTests {
@Autowired
private JavaMailSender mailSender;
@Test
public void testMail() throws MessagingException {
MimeMessage mimeMessage = mailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
//发件人
helper.setFrom("[email protected]");
//收件人
helper.setTo("[email protected]");
//标题
helper.setSubject("subject");
//文本
helper.setText("message text");
//附件
helper.addAttachment("downFile",new File("D:\\cygwin64\\home\\workspace3\\learn-demo\\zookeeper\\src\\test\\java\\com\\tzxylao\\design\\ZookeeperApplicationTests.java"));
mailSender.send(mimeMessage);
}
}
オリジナル住所ます。https://www.cnblogs.com/sky-chen/p/10710516.html