[Solved] java send mail tcmime.2648.2742.2958.bin encoding error

Service startup initialization

Direct initialization at startup for encoding settings

private void init() {<!-- -->
// The default java parameter splitlongparameters about the mailbox is true, that is, it will be processed as .bin if it is too long
// We can close it manually
    System.setProperty("mail.mime.splitlongparameters", "false");
}

Email sending set encoding format

When getting the email object, configure the parameter settings

//Set the encoding format to UTF-8
 properties.setProperty("mail.mime.charset", "UTF-8");
 public Session initMail() {<!-- -->
        try {<!-- -->
            //Create a configuration file and save it
            Properties properties = new Properties();
            properties.setProperty("mail.host", "smtp.qq.com");
            properties.setProperty("mail.transport.protocol", "smtp");
            properties.setProperty("mail.smtp.auth", "true");
            properties.setProperty("mail.mime.charset", "UTF-8");
            //QQ has a feature to set SSL encryption
            MailSSLSocketFactory sf = null;
            sf = new MailSSLSocketFactory();
            sf.setTrustAllHosts(true);
            properties.put("mail.smtp.ssl.enable", "true");
            properties.put("mail.smtp.ssl.socketFactory", sf);
            //Create a session object
            Session session = Session.getDefaultInstance(properties, new Authenticator() {<!-- -->
                @Override
                protected PasswordAuthentication getPasswordAuthentication() {<!-- -->
                    return new PasswordAuthentication(qqUserName, qqPassWord);
                }
            });
// //Enable debug mode
            session.setDebug(true);
            return session;
        } catch (Exception e) {<!-- -->
            e.printStackTrace();
        }
        return null;
    }