System.out.println("yes...............................!"); } } ------------------------ javax.mail.SendFailedException: Sending failed; nested exception is: javax.mail.MessagingException: Could not connect to SMTP host: gmail.com , port: 25; nested exception is: java.net.ConnectException: Connection timed out: connect at javax.mail.Transport.send0(Transport.java:219) at javax.mail.Transport.send(Transport.java:81) at SimpleSendMessage.main(SimpleSendMessage.java:40)
--------------- i connected to net but why this problem is coming please clear me i will be thankfull to you. bye
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35249
7
posted
0
I doubt that gmail.com is running a mail server; it's probably smtp.gmail.com or something similar.
You'll also need to use authentication. Check this JavaMail introduction for how that works.
Sending mail from a Java application is so easy. 1.first download mail API from SUN's website (mail_api.rar) 2.Include mail.jar and activation.jar to your IDE's libraries 3.Use following code to send email(example configured for gmail) enjoy...
Session session = Session.getDefaultInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication(){ // buraya gmail mail adresinizi ve sifrenizi girmelisiniz. return new PasswordAuthentication("username@gmail.com", "password here"); } });
InternetAddress[] addressTo = new InternetAddress[recipients.length]; for (int i = 0; i < recipients.length; i++) { addressTo[i] = new InternetAddress(recipients[i]); } msg.setRecipients(Message.RecipientType.TO, addressTo);
public static void main(String args[]) throws Exception { Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); new GoogleMailSender().sendSSLMessage( sendTo, emailSubjectTxt, emailMsgTxt, emailFromAddress); System.out.println("Sucessfully Sent mail to All Users"); }//end main
}//end class
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.