Hi folks,

this is not a commons-email issue but the SMTP server decides to reject
the email due to

"<jiteshbdun...@gmail.com>: Relay access denied"

and this is actually a message from the SMTP server

It seems that your mail server is not set up to relay mails to the
public - to verify that point send an email to "jit...@it.iitb.ac.in"
because no relaying is required. You can also set the debug mode using
Email.setDebug(true) to see the messages being exchanged between your
client and SMTP server.

Cheers,

Siegfried Goeschl
 
jitesh dundas wrote:
> Hi Andres,
>
> I did that too.
>
> Code Used:-
> --------------------------
> 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
>         {
>             org.apache.commons.mail.SimpleEmail em = new
> org.apache.commons.mail.SimpleEmail();
>             em.setHostName("smtp-auth.iitb.ac.in");
>             em.setSmtpPort(25);
>             em.setAuthentication("jitesh","jitesh*");
>             em.addTo("jiteshbdun...@gmail.com");
>             em.setFrom("jit...@it.iitb.ac.in");
>             em.setSubject("Test Mail Using Commons API");
>             em.setMsg("Simple Test Mail");
>             em.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:25
> org.apache.commons.mail.EmailException: Sending the email to the following
> serve
> r failed : smtp-auth.iitb.ac.in:25
>         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.SendFailedException: Invalid Addresses;
>   nested exception is:
>         com.sun.mail.smtp.SMTPAddressFailedException: 554
> <jiteshbdun...@gmail.c
> om>: Relay access denied
>
>         at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1446)
>         at
> com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:736)
>         at javax.mail.Transport.send0(Transport.java:191)
>         at javax.mail.Transport.send(Transport.java:120)
>         at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1128)
>         ... 2 more
> Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 554
> <jiteshbdun...@gmai
> l.com>: Relay access denied
>
>         at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1344)
>         ... 6 more
>
> C:\Program Files\Java\jdk1.5.0_10\bin>
> ------------------------
>
> Are there any connection./network settings on my machine and/or the SMTP
> Server to be set..
>
> Regards,
> Jitesh
>
> 2009/7/21 Andrés M. Luna <and...@digiworks.com.mx>
>
>   
>> Hi,
>>
>> Is your smtp port: 80??
>> ...
>> email.setSmtpPort(80);
>> ...
>>
>> Try using port: 25
>> ...
>> email.setSmtpPort(25);
>> ...
>>
>> Regards,
>> Andres M. Luna
>>
>> -----Original Message-----
>> From: jitesh dundas [mailto:jiteshbdun...@gmail.com]
>> Sent: Tuesday, July 21, 2009 7:17 AM
>> To: user@commons.apache.org
>> Subject: [EMAIL]-[Error In Sending Email Using Commons Email API]
>>
>> 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("jiteshbdun...@gmail.com");
>>            email.setFrom("jit...@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
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
>> For additional commands, e-mail: user-h...@commons.apache.org
>>
>>
>>     
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org

Reply via email to