السلام عليكم ورحمة الله وبركاته
أنا أتيت مسبقاً أود التعلم على الـ javamail وكيفية تثبيت البرنامج والحمد الله وجدتها ولكن لدي الآن بعض المشاكل
وأود من حضرتكم مساعدتي فيها فقد حصلت على الكود ولكن عند عمل run لا يظهر الـ output فيظهر
--------------------Configuration: <Default>-------------------- Exception in thread "main" javax.mail.MessagingException: Could not connect to SMTP host: 192.168.10.205, port: 25; nested exception is: java.net.ConnectException: Connection timed out: connect at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1934) at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638) at javax.mail.Service.connect(Service.java:295) at javax.mail.Service.connect(Service.java:176) at javax.mail.Service.connect(Service.java:125) at javax.mail.Transport.send0(Transport.java:194) at javax.mail.Transport.send(Transport.java:124) at SMTPClient.main(SMTPClient.java:40) Caused by: java.net.ConnectException: Connection timed out: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:69) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:316) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:177) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:164) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:154) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:390) at java.net.Socket.connect(Socket.java:578) at java.net.Socket.connect(Socket.java:527) at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:288) at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:231) at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1900) ... 7 more Process completed.
قد تكون لدي أخطاء في وضع البكج في CLASSPATH لذلك سأضعه
.;C:\Program Files\Java\javamail-1.4.4\mail.jar;C:\Program Files\Java\javamail-1.4.4;C:\Program Files\Java\jaf-1.1.1\activation.jar;C:\Program Files\Java\jre7\lib\ext\QTJava.zip
import javax.mail.*;
import javax.mail.internet.*;
public class SMTPClient {
public static void main(String args[]) throws Exception {
String host = "192.168.10.205";
String from = "test@localhost";
String to = "test@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);
// Create a default MimeMessage object.
MimeMessage message = new MimeMessage(session);
// Set the RFC 822 "From" header field using the
// value of the InternetAddress.getLocalAddress method.
message.setFrom(new InternetAddress(from));
// Add the given addresses to the specified recipient type.
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
// Set the "Subject" header field.
message.setSubject("hi..!");
// Sets the given String as this part's content,
// with a MIME type of "text/plain".
message.setText("Hi ......");
// Send message
Transport.send(message);
System.out.println("Message Send.....");
}
}
import java.util.*;
وهذا الكود رجاءً أعطوني إجابات شافية فالتقديم الأولي للمشروع الأسبوع الجاي و أنا أبغى أعمل تست لهذا الكود لأستطيع كتابة كود بنفسي
وشكراً مقدماً
