を電子メールの送信、私は自分のアカウント に、一般的な電子メールを送り、小さなのprogrammを実行しようとする。しかし、私は例外を取得:Javaのメールで
javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 553 We do not relay non-local mail, sorry.
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1873)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1120)
at javax.mail.Transport.send0(Transport.java:195)
at javax.mail.Transport.send(Transport.java:124)
at SendEmail.main(SendEmail.java:54)
Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 553 We do not relay non-local mail, sorry.
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1724)
... 4 more
これは使用して私のコード
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
public class SendEmail
{
public static void main(String [] args)
{
// Recipient's email ID needs to be mentioned.
String to = "[email protected]";
// Sender's email ID needs to be mentioned
String from = "[email protected]";
// Assuming you are sending email from localhost
String host = "localhost";
// Get system properties
Properties properties = System.getProperties();
// Setup mail server
properties.setProperty("mail.smtp.host", host);
// Get the default Session object.
Session session = Session.getDefaultInstance(properties);
try{
// Create a default MimeMessage object.
MimeMessage message = new MimeMessage(session);
// Set From: header field of the header.
message.setFrom(new InternetAddress(from));
// Set To: header field of the header.
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
// Set Subject: header field
message.setSubject("This is the Subject Line!");
// Now set the actual message
message.setText("This is actual message");
// Send message
Transport.send(message);
System.out.println("Sent message successfully....");
}catch (MessagingException mex) {
mex.printStackTrace();
}
}
}
イムですMercury Serverを実行するためのXAMPPコントロールパネル。港は25,79,105,106,110,143,2224です。私はこれに新しいので、多分誰かが私を正しい方向に押し込むことができます。
使用しているサーバーから意味のあるメッセージが返されました。 *私たちは非ローカルメールを中継しません。ごめんなさい。* –