commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jitesh dundas <jiteshbdun...@gmail.com>
Subject [EMAIL]-[Error In Sending Email Using Commons Email API]
Date Tue, 21 Jul 2009 12:16:36 GMT
Dear Friends,

I am using the Commons Mail API. The code mentioned below is compiling fine
but it gives the run time error:-

Code :-
---------------------
import java.io.*;
import java.net.InetAddress;
import java.util.Properties;
import java.util.Date;

import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;

import org.apache.commons.mail.*;

public class sendCommonsMail
{

    public static void main( String args[])
    {
        int flagmailesent = 1;

        try
        {
            SimpleEmail email = new SimpleEmail();
            email.setHostName("****-****.****.**.**");
            email.setSmtpPort(80);
            email.setAuthentication("******","*******");
            email.addTo("jiteshbdundas@gmail.com");
            email.setFrom("jitesh@it.iitb.ac.in");
            email.setSubject("Test Mail Using Commons API");
            email.setMsg("Simple Test Mail");
            email.send();
        }
        catch( org.apache.commons.mail.EmailException emailex)
        {
            System.out.println("Commons Exception="+emailex);
            emailex.printStackTrace();
        }
    }
}
--------------------


Error :-
----------------------
C:\Program Files\Java\jdk1.5.0_10\bin>java sendCommonsMail
Commons Exception=org.apache.commons.mail.EmailException: Sending the email
to t
he following server failed : smtp-auth.iitb.ac.in:80
org.apache.commons.mail.EmailException: Sending the email to the following
serve
r failed : smtp-auth.iitb.ac.in:80
        at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1138)
        at org.apache.commons.mail.Email.send(Email.java:1163)
        at sendCommonsMail.main(sendCommonsMail.java:29)
Caused by: javax.mail.MessagingException: Could not connect to SMTP host:
smtp-a
uth.iitb.ac.in, port: 80;
  nested exception is:
        java.net.ConnectException: Connection timed out: connect
        at
com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1545)
        at
com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:45
3)
        at javax.mail.Service.connect(Service.java:313)
        at javax.mail.Service.connect(Service.java:172)
        at javax.mail.Service.connect(Service.java:121)
        at javax.mail.Transport.send0(Transport.java:190)
        at javax.mail.Transport.send(Transport.java:120)
        at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1128)
        ... 2 more
Caused by: java.net.ConnectException: Connection timed out: connect
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
        at
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:519)
        at java.net.Socket.connect(Socket.java:469)
        at
com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:267)
        at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:227)
        at
com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1511)
        ... 9 more

C:\Program Files\Java\jdk1.5.0_10\bin>
---------------------

Please help.

Thanks & Regards,
Jitesh Dundas

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message