开发者社区> 问答> 正文

企业邮箱通过java mail 访问报错535错误



我使用java mail,通过我的阿里云企业邮箱发送邮件,一直报以上错误,哪位大神能给点建议?代码如下所示:
final Properties props = new Properties();
        // 表示SMTP发送邮件,需要进行身份验证
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.host", "smtpdm.aliyun.com");
        props.put("mail.smtp.port", "25");  
        // 发件人的账号
        props.put("mail.user", " service@51findjob.com");
        // 访问SMTP服务时需要提供的密码
        props.put("mail.password", "**************");


        // 构建授权信息,用于进行SMTP进行身份验证
        Authenticator authenticator = new Authenticator() {
            @Override
            protected PasswordAuthentication getPasswordAuthentication() {
                // 用户名、密码
                String userName = props.getProperty("mail.user");
                String password = props.getProperty("mail.password");
                return new PasswordAuthentication(userName, password);
            }
        };
        // 使用环境属性和授权信息,创建邮件会话
        Session mailSession = Session.getInstance(props, authenticator);
        // 创建邮件消息
        MimeMessage message = new MimeMessage(mailSession);
        // 设置发件人
        InternetAddress form = new InternetAddress(props.getProperty("mail.user"));
        message.setFrom(form);


        // 设置收件人
        InternetAddress to = new InternetAddress(" 910022916@qq.com");
        message.setRecipient(MimeMessage.RecipientType.TO, to);


        // 设置邮件标题
        message.setSubject("测试邮件");
        // 设置邮件的内容体
        message.setContent("测试的HTML邮件", "text/html;charset=UTF-8");


        // 发送邮件
        Transport.send(message);

展开
收起
myk 2016-04-01 18:57:16 9293 0
1 条回答
写回答
取消 提交回答
  • 阿里云论坛版主,QQ 1978638808
    企业邮箱问题建议通过工单获取。
    2016-04-01 19:33:23
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Spring Cloud Alibaba - 重新定义 Java Cloud-Native 立即下载
The Reactive Cloud Native Arch 立即下载
JAVA开发手册1.5.0 立即下载