سلام عليكم...
انا كتبت هذا الكود ولكن...
import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
public class email{
private static void send(String host, String from, String to, String subject, String time){
//setup the contents of the e-mail message
String contents = ("Email content");
//set the properties
Properties prop = System.getProperties();
//set up the mail server
prop.put("mail.smtp.host", host);
//create a new session
Session session = Session.getDefaultInstance(prop, null);
try {
//define the message
MimeMessage message = new MimeMessage(session);
//set who the message is from
message.setFrom(new InternetAddress("Timetables@ulst.ac.uk"));
//set who the message is to
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
//set the message subject
message.setSubject("Details of Meeting " + subject);
//set the message content
message.setContent(contents + "footer", "text/plain");
//send the message
Transport.send(message);
//exception handling
} catch (MessagingException mex) {
System.out.println("n--Exception handling in sending email");
mex.printStackTrace();
System.out.println();
Exception ex = mex;
do {
if (ex instanceof SendFailedException) {
SendFailedException sfex = (SendFailedException)ex;
Address[] invalid = sfex.getInvalidAddresses();
if (invalid != null) {
System.out.println(" ** Invalid Address");
if (invalid != null) {
for (int i = 0; i < invalid.length; i++)
System.out.println(" " + invalid);
}
}
Address[] validUnsent = sfex.getValidUnsentAddresses();
if (validUnsent != null) {
System.out.println(" ** ValidUnsent Address");
if (validUnsent != null) {
for (int i = 0; i < validUnsent.length; i++)
System.out.println(" "+validUnsent);
}
}
Address[] validSent = sfex.getValidSentAddresses();
if (validSent != null) {
System.out.println(" ** ValidSent Address");
if (validSent != null) {
for (int i = 0; i < validSent.length; i++)
System.out.println(" "+validSent);
}
}
}
System.out.println();
if (ex instanceof MessagingException)
ex = ((MessagingException)ex).getNextException();
else
ex = null;
} while (ex != null);
}//end of catch
}//end of send email
public static void main(String [] args){
send("213.230.9.11", "memonono@yahoo.com", "memonono@mailcity.com", "Conformation from wael", "Whenever");}
}وهذه رسالة الخطاء الذي يظهر
طبعا run-time error
والبرنامج successfully compiled
n--Exception handling in sending email javax.mail.SendFailedException: Sending failed; nested exception is: class javax.mail.MessagingException: Could not connect to SMTP host: 213 .230.9.11, port: 25; nested exception is: java.net.ConnectException: Connection refused: connect at javax.mail.Transport.send0(Transport.java:218) at javax.mail.Transport.send(Transport.java:80) at email.send(email.java:43) at email.main(email.java:92)
طبعا بدلا من213.230.9.11
جربت smtp.yahoo.com
ولكن لا فائدة
هل للبروكسي تأثير ؟؟؟
