Skip to main content

Send Email Through NetEase Enterprise Mail with Spring Boot

· One min read
Apache Wangye
Software developer and technical writer

Spring Boot sends SMTP mail through JavaMailSender. Use the exact server, port, encryption mode, and authorization credential supplied by the enterprise mailbox administrator.

spring:
mail:
host: smtp.qiye.163.com
port: 465
username: user@example.com
password: ${MAIL_PASSWORD}
protocol: smtp
properties:
mail.smtp.auth: true
mail.smtp.ssl.enable: true
mail.smtp.connectiontimeout: 10000
mail.smtp.timeout: 10000
mail.smtp.writetimeout: 10000

A basic send operation:

SimpleMailMessage message = new SimpleMailMessage();
message.setFrom("user@example.com");
message.setTo("receiver@example.com");
message.setSubject("Test message");
message.setText("Mail sent by Spring Boot");
mailSender.send(message);

Some accounts require an app-specific authorization code rather than the login password. Authentication failures can also result from an incorrect sender address, blocked SMTP service, TLS/port mismatch, DNS, firewall rules, or provider rate limits. Keep credentials outside source control.

Page views: --

Total views -- · Visitors --