我遇到了一些未知类型的错误,我发送邮件的代码如下
String mail_smtp_host=directoryPath("mail_smtp_host");
final String mail_host_username=directoryPath("mail_host_username");
final String mail_host_password=directoryPath("mail_host_password");
String mail_smtp_port=directoryPath("mail_smtp_port");
String set_from_emailid=directoryPath("set_from_emailid");
String set_from_emailid3=directoryPath("set_from_emailid3");
String set_from_emailid4=directoryPath("set_from_emailid4");
我从属性文件中读取的所有邮件
Properties props = new Properties();
props.put("mail.smtp.host", mail_smtp_host);
props.put("mail.smtp.socketFactory.port", "25");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", mail_smtp_port);
Session session = Session.getDefaultInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(mail_host_username,mail_host_password);
}
});
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(mail_host_username));
message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(checkemail));
final String mail=""+set_from_emailid+","+set_from_emailid4+","+set_from_emailid3+"";
message.addRecipients(Message.RecipientType.BCC,
InternetAddress.parse(mail));
在这里我设置了多个密件抄送邮件 id
mess = "Hello"
message.setContent(mess, "text/html;charset=utf-8");
Transport.send(message);
它在我的本地机器上工作,邮件被发送到密件抄送中的相关方,但是一旦部署在 ma 测试服务器上,它就会显示以下错误。
javax.mail.SendFailedException: Invalid Addresses; nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 501 5.5.2 RCPT TO syntax error
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1196)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:584
启用以查找问题。请帮忙
谢谢