public static void sendMail(String to, String title, String content) throws Exception {
        if (!Checker.isEmail(to)) {
            throw new Exception("this email address is not valid. please check it again");
        }
        // 获取系统属性
        Properties properties = System.getProperties();
        // 设置邮件服务器
        properties.setProperty("mail.smtp.host", host);
        if (port > 0) {
            properties.setProperty("mail.smtp.port", String.valueOf(port));
        }
        properties.put("mail.smtp.auth", "true");
        MailSSLSocketFactory sf;
        sf = new MailSSLSocketFactory();
        sf.setTrustAllHosts(true);
        properties.put("mail.smtp.ssl.enable", sslEnable);
        properties.put("mail.smtp.ssl.socketFactory", sf);
        // 获取session对象
        Session session = Session.getInstance(properties, new Authenticator() {
            @Override
            public PasswordAuthentication getPasswordAuthentication() {
                // 发件人邮件用户名、密码
                return new PasswordAuthentication(from, key);
            }
        });

        // 创建默认的MimeMessage对象
        MimeMessage message = new MimeMessage(session);
        // Set From:头部头字段
        message.setFrom(new InternetAddress(from, personal, "UTF-8"));
        // Set To:头部头字段
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
        // Set Subject:头部头字段
        message.setSubject(title, "UTF-8");
        // 设置消息体
        message.setContent(content, "text/html;charset=UTF-8");
        message.setSentDate(new Date());
        // 发送消息
        Transport.send(message);
    }
public static void sendMail ( String to , String title , String content ) throws Exception { if ( ! Checker . isEmail ( to ) ) { throw new Exception ( "this email address is not valid. please check it again" ) ; } Properties properties = System . getProperties ( ) ; properties . setProperty ( "mail.smtp.host" , host ) ; if ( port > 0 ) { properties . setProperty ( "mail.smtp.port" , String . valueOf ( port ) ) ; } properties . put ( "mail.smtp.auth" , "true" ) ; MailSSLSocketFactory sf ; sf = new MailSSLSocketFactory ( ) ; sf . setTrustAllHosts ( true ) ; properties . put ( "mail.smtp.ssl.enable" , sslEnable ) ; properties . put ( "mail.smtp.ssl.socketFactory" , sf ) ; Session session = Session . getInstance ( properties , new Authenticator ( ) { @ Override public PasswordAuthentication getPasswordAuthentication ( ) { return new PasswordAuthentication ( from , key ) ; } } ) ; MimeMessage message = new MimeMessage ( session ) ; message . setFrom ( new InternetAddress ( from , personal , "UTF-8" ) ) ; message . addRecipient ( Message . RecipientType . TO , new InternetAddress ( to ) ) ; message . setSubject ( title , "UTF-8" ) ; message . setContent ( content , "text/html;charset=UTF-8" ) ; message . setSentDate ( new Date ( ) ) ; Transport . send ( message ) ; }
发送邮件，调用此方法前请先检查邮件服务器是否已经设置，如果没有设置，请先设置{@link MailSender#setHost(String)}， 如不设置将使用默认的QQ邮件服务器

@param to 收件箱
@param title 标题
@param content 内容

@throws Exception 异常