估计和 mail.smtp.auth  有关系。

解决方案 »

  1.   

    这是我自己写发送Email的,直接调方法只需要传收件箱,标题,跟正文就行了。代码里面把你自己用来发件的信箱改下就行了。希望能对你有帮助
    package com.kernel.ktvos.util;import java.util.Properties;import javax.mail.Authenticator;
    import javax.mail.Message;
    import javax.mail.MessagingException;
    import javax.mail.PasswordAuthentication;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.internet.AddressException;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeMessage;public class EmailUtils { static class Inclass implements Runnable {
    private Message msg; private Inclass(Message msg) {
    this.msg = msg; } public void run() {
    try {
    // 发送邮件
    Transport.send(msg);
    System.out.println("邮箱发送成功");
    } catch (MessagingException e) {
    e.printStackTrace();
    }
    } } public static void sendEmail(String to, String topic, String message) {
    Properties pro = new Properties();
    pro.put("mail.smtp.host", "smtp.163.com");// 发送的邮件服务器
    pro.put("mail.smtp.auth", "true");// 配置是否验证账号 // 获得Session,验证发送者的账号密码
    Session session = Session.getDefaultInstance(pro, new Authenticator() {
    @Override
    protected PasswordAuthentication getPasswordAuthentication() {
    return new PasswordAuthentication("[email protected]",
    "kerneljava");
    }
    }); // 获得store对象
    Message msg = new MimeMessage(session); try {
    // 设置邮件接收者
    msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
    // 设置邮件的主题
    msg.setSubject(topic);
    // 设置邮件的发送者
    msg.setFrom(new InternetAddress("[email protected]"));
    // 邮件的内容
    msg.setContent(message, "text/html;charset=utf-8"); // 异步处理
    Inclass inclass = new Inclass(msg);
    Thread thread = new Thread(inclass);
    thread.start(); } catch (AddressException e) {
    System.out.println("地址错误 ");
    } catch (MessagingException e) {
    e.printStackTrace();
    } }}