xrl2012 2014-04-11 03:31
浏览 3964

Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 553 sorry

package com.gotobus.util.email;
import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.SendFailedException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

import com.sun.mail.smtp.SMTPAddressFailedException;
public class SendMail {

/**
 * @param args
 */
public static void main(String[] args) {
    String host = "mail.gotobus.com";   //发件人使用发邮件的电子信箱服务器
    String from = "no-reply@gotobus.com";    //发邮件的出发地(发件人的信箱)
    String to = "wushu201404@gmail.com";   //发邮件的目的地(收件人信箱)
 // String to="mark@gotobus.com";

   Properties props = System.getProperties();
   props.put("mail.smtp.host", host);
   props.put("mail.smtp.auth", "false"); //这样才能通过验证
   props.put("mail.transport.protocol", "POP3");
   props.put("mail.smtp.port", "25");   

//   MyAuthenticator myauth = new MyAuthenticator();
   Session session = Session.getDefaultInstance(props, null);

// Session session = Session.getInstance(props);

  MimeMessage message = new MimeMessage(session);

    try {
        message.setFrom(new InternetAddress(from));
        message.addRecipient(Message.RecipientType.TO,
          new InternetAddress(to));
        message.setSubject("测试程序--no-reply--!");
        message.setText("这是用java写的发送电子邮件的测试程序99999wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwa!");
        message.saveChanges();

       try {
           Transport.send(message);
       } catch (SMTPAddressFailedException e) {
           throw new SendFailedException("Unable to send to " + to, e);
          }



        System.out.println("=======success=====");
    } catch (AddressException e) {
        e.printStackTrace();
    } catch (MessagingException e) {
        e.printStackTrace();
    }



}

}
----具体情况描述--------
这个案例是用javamail实现不需要校验身份信息实现邮件发送的功能,目前自己所用的是企业内部邮箱,代码可以实现的是给内部邮箱发件。但换成qq.163.gmail等邮件时,出现了上面的报错。。。。。。但使用perl语言时可以顺利转发,所以,邮箱账户应该不存在问题,求助大神诊断!!!!!!!!!!!!感激不尽!!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Python时间序列如何拟合疏系数模型
    • ¥15 求学软件的前人们指明方向🥺
    • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
    • ¥15 MCNP里如何定义多个源?
    • ¥20 双层网络上信息-疾病传播
    • ¥50 paddlepaddle pinn
    • ¥20 idea运行测试代码报错问题
    • ¥15 网络监控:网络故障告警通知
    • ¥15 django项目运行报编码错误
    • ¥15 STM32驱动继电器