Posted By:
sunil_telkar
Posted On:
Tuesday, September 7, 2004 06:54 AM
I get the following runtime exception when i try to send email through java . D:demo>java SendEmail Exception in thread "main" javax.mail.SendFailedException: Sending failed; nested exception is: class javax.mail.MessagingException: Could not connect to SMTP host: smtp.mac.com, port: 25 at javax.mail.Transport.send0(Transport.java:218) at javax.mail.Transport.send(Transport.java:80) at SendEmail.main(SendEmail.java:21) Following is the java source code . import java.util.*; import javax.mail.*; import javax.mail.internet.*; public cla
More>>
I get the following runtime exception when i try to send
email through java .
D:demo>java SendEmail
Exception in thread "main" javax.mail.SendFailedException: Sending failed;
nested exception is:
class javax.mail.MessagingException: Could not
connect to SMTP host: smtp.mac.com, port: 25
at javax.mail.Transport.send0(Transport.java:218)
at javax.mail.Transport.send(Transport.java:80)
at SendEmail.main(SendEmail.java:21)
Following is the java source code .
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
public class SendEmail {
public static void main(String[] args) throws
MessagingException {
String smtphost = "smtp.mac.com";
String fromaddress = "glen@mac.com";
String toaddress = "glen@mac.com";
Properties prop = System.getProperties();
prop.put("mail.smtp.host",smtphost);
Session session = Session.getInstance (prop,null);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(fromaddress));
message.setRecipient(Message.RecipientType.TO, new InternetAddress(toaddress));
message.setSubject("Java mail");
message.setText("Did it works");
Transport.send(message);
System.out.println("mail sent");
}
}
I have the following files in classpath
.;c:jdk1.3.1_08lib;d:jafactivation.jar;d:javamailmail.jar;d:javamailimap.jar;
d:javamailsmtp.jar;d:javamailpop3.jar;d:javamailmailapi.jar
I am able to send email through Outlook with smpt host
as smtp.mac.com .Can anybody of you guide me if any setting
is remaining .
<<Less