我试图从Web应用程序发送邮件时,此异常:Java邮件API例外
com.sun.mail.smtp.SMTPSendFailedException: 550 5.7.1 Missing
or literal domains not allowed
我使用类似下面的代码性能。
Properties props = new Properties();
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.host", "smtp.verizon.net");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
我还使用身份验证方法使用用户名和密码对用户进行身份验证。
只有当我通过身份验证时,我才得到成功消息。当我去到名为transport.sen(message)
的行时,我得到了异常。
this is my full code..
try {
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(
to));
// message.addRecipient(Message.RecipientType.CC, new InternetAddress(
// cc));
// message.addRecipient(Message.RecipientType.BCC,
// new InternetAddress(bcc));
message.setSubject("TEST...!!!!!!!");
Multipart multipart = new MimeMultipart();
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart
.setText("Dear Sir, Mail Testing");
multipart.addBodyPart(messageBodyPart);
messageBodyPart.setText("Hao test");
message.setText("Kader here");
message.setContent(multipart);
MailcapCommandMap mc = (MailcapCommandMap) CommandMap.getDefaultCommandMap();
mc.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html");
mc.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml");
mc.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain");
mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed");
mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822");
CommandMap.setDefaultCommandMap(mc);
Transport transport = session.getTransport();
transport.connect();
Transport.send(message);
transport.close();
System.out.println("Sent message successfully....");
} catch (MessagingException mex) {
mex.printStackTrace();
}
如何设置邮件recipeints,发件人和内容?请张贴代码 – Abubakkar 2013-04-27 07:10:33
这似乎与Verizon有关。也许这些帮助:http://forums.verizon.com/t5/Verizon-net-Email/Win7-receive-but-no-send/td-p/312309和http://www.vistax64.com/vista- mail/197859-window-mail-gone-haywire-help.html – dcernahoschi 2013-04-27 07:13:14