0
Apacheのcommons mail APIを使用して、Javaプログラムから電子メールを送信しています。Apache電子メールAPI:例外を取得する - 無効な「To」アドレス
次はJavaコードです。
public static void sendSimpleMail() throws Exception {
Email email = new SimpleEmail();
email.setSmtpPort(25);
email.setDebug(false);
email.setHostName("localhost");
email.setFrom("[email protected]"); // Is this correct ?Do we need this?
email.setSubject("Hi");
email.setMsg("This is a test mail ... :-)");
email.addTo("[email protected]");
email.setTLS(true);
email.send();
System.out.println("Mail sent!");
}
私はFree SMTP serverは、有効なDNSサーバを使用して、ポート25上で実行されています。
今、私がプログラムを実行すると、次の例外が発生します。
Exception in thread "main" org.apache.commons.mail.EmailException: Sending the email to the following server failed : localhost:25
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1242)
at org.apache.commons.mail.Email.send(Email.java:1267)
at TestMail.sendSimpleMail(TestMail.java:26)
at TestMail.main(TestMail.java:13)
Caused by: com.sun.mail.smtp.SMTPSendFailedException:
550 Invalid recipient: [email protected]
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1388)
at com.sun.mail.smtp.SMTPTransport.finishData(SMTPTransport.java:1215)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:586)
at javax.mail.Transport.send0(Transport.java:169)
at javax.mail.Transport.send(Transport.java:98)
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1232)
... 3 more
私の電子メールIDは、非常に有効な電子メールIDです。なぜプログラムがこのようなエラーを出すのですか?
ローカルサーバーは稼動しており、インターネットに送信できますか? – timbooo
はい。そうです。しかし、問題は何か異なるようです。それが言っているように、 – vinoth