发送邮件(@163.com)

来源:互联网 发布:俄罗斯域名注册商 编辑:程序博客网 时间:2024/06/06 00:03

1.添加依赖,

      commons-email  等等

@Test

    public void sendMail() throws EmailException, MalformedURLException, UnsupportedEncodingException {
        //可以添加发送响应的类

        HtmlEmail email = new HtmlEmail();

       //HostName的配置

        email.setHostName("smtp.163.com");

       //发送文件的邮箱地址

        email.setAuthenticator(new DefaultAuthenticator("ycdl_mail@163.com", "1qaz2wsx"));
        email.setSSLOnConnect(true);

      //接收文件的邮箱地址

        email.addTo("16910735@qq.com", "");

     //发送文件的邮箱及密码

        email.setFrom("ycdl_mail@163.com", "wq");
        email.setSubject("账号激活");

        email.setCharset("UTF-8");

        // embed the image and get the content id
        URL url = new URL("http://www.apache.org/images/asf_logo_wide.gif");
        String cid = email.embed(url, "Apache logo");
        // set the html message
        String content="<html><meta charset=\"utf-8\" />" +
                "账号激活地址:<a href='http://localhost:8080/user/xxxxxxxxxxxx'>http://localhost:8080/user/xxxxxxxxxxxx</a>"+
                "</html>";
        email.setHtmlMsg(new String(content.getBytes(),"UTF-8"));
        // set the alternative message;文件的内容
        email.setTextMsg("此邮件不需要回复");

        // send the email;确认发送

        email.send();

    }
阅读全文
'); })();
0 0
原创粉丝点击
热门IT博客
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 首款5g手机 家庭宽带哪家好 电信网络价格 5g新款手机 宽带运营商电话 五g手机 什么网络好用 现在5g手机有哪些 5g手机推荐 5g股票 5g智能手机 电信包月宽带 即将新出的手机 5g有什么用 500元以下的智能手机 3000元买什么手机好 宽带20兆一年多少钱 性价比超高的千元手机 现在5g 5g概念股龙头 路由器24g和5g需要都开吗 5g是啥 什么是移动宽带 移动50兆宽带怎么样 5g网络需要换手机吗 中兴5g 歌华有线宽带营业厅 手机对比参数配置比较 国产5g手机有哪些 移动宽带网速 新出的手机 5g手机图片 电信宽带和移动宽带哪个好 电信无线网络 5g产业 牵宽带要多少钱 网络管理中心 安电信宽带多少钱 手机5g 宽带费怎么交 5g的手机