求救: javamail 程序只能在同一个域内发送!!

woodwoodfish 2003-10-16 06:24:37
比如:
a@domain1.com 可以发邮件给所有 @domain1.com的用户,但如果是发邮件
给*@domain2.com或者其他域中的用户的时候,就会报错:
javax.mail.SendFailedException: Sending failed;
nested exception is: javax.mail.SendFailedException: Invalid Addresses;
nested exception is: javax.mail.SendFailedException: 550 <*@domain2.com>: Invalid User

代码如下:

//the mail client
public MailClient(String user, String passwe String host) {
PasswordAuthentication authentication = new PasswordAuthentication(user, passwd);
Properties props = new Properties();
props.put("mail.user", user);
props.put("mail.host", host);
props.put("mail.store.protocol", "pop3");
props.put("mail.transport.protocol", "smtp");
session = Session.getInstance(props, this);
}

public PasswordAuthentication getPasswordAuthentication() {
return authentication;
}

//send message
public void sendMessage(
String to, String subject, String content) throws
MessagingException {
MimeMessage msg = new MimeMessage(session);
msg.addRecipients(Message.RecipientType.TO, to);
msg.setSubject(subject);
msg.setText(content);
Transport.send(msg);
}
...全文
39 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
woodwoodfish 2003-10-17
  • 打赏
  • 举报
回复
地址绝对正确的,我用那个to的地址给to自己发也可以收成功

现在的情况是只要是同一个域的地址发送就没问题,反之就出错

有次出过这样的错: Recipient unknown 的错误
liushenling 2003-10-16
  • 打赏
  • 举报
回复
看来是地址不对阿,要么是你的host地址不对,要么是你的to地址不对!检查一下啊
9731boy 2003-10-16
  • 打赏
  • 举报
回复
你try{}一下吧.
Invalid Addresses; 好像是提示地址错误吧.

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧