zoukankan      html  css  js  c++  java
  • mail

    http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#mail

    # 添加依赖包
    ```
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context-support</artifactId>
            </dependency>
            <dependency>
                <groupId>com.sun.mail</groupId>
                <artifactId>javax.mail</artifactId>
                <version>1.5.4</version>
            </dependency>
    ```

    # 编写java代码
    ```
        public static void sendMail() {
            SimpleMailMessage msg = new SimpleMailMessage();
            msg.setFrom("weichunhe@netfinworks.com");
            msg.setTo("1329555958@qq.com");
            msg.setText("hello test mail");
            msg.setSubject("wch");
     
            JavaMailSenderImpl sender = new JavaMailSenderImpl();
            sender.setHost("smtp.exmail.qq.com");
            sender.setPort(465);
            sender.setUsername("weichunhe@netfinworks.com");
            sender.setPassword("wid2");
            Properties properties = new Properties();
            properties.put("mail.smtp.ssl.enable", true);
    //        properties.put("mail.smtp.auth", "true");
    //        properties.put("mail.smtp.socketFactory.class",
    //                SSLSocketFactory.class.getName());
            sender.setJavaMailProperties(properties);
            sender.send(msg);
     
        }
    ```




  • 相关阅读:
    DAY10-MYSQL表操作
    DAY10-MYSQL完整性约束
    DAY10-MYSQL数据类型
    DAY10-MYSQL存储引擎
    DAY10-MYSQL库操作
    017.2 基本数据类型对象包装类
    017.1 stringBuffer
    016.2 String
    16.1 eclipse设置
    015.5线程常见用法(面试题)
  • 原文地址:https://www.cnblogs.com/vvch/p/5465600.html
Copyright © 2011-2022 走看看