Sending Mail from jsp

Hi guys,
can anyone help me out of this problem ??
I have written a piece of code which sends mail from a jsp page.
When I use the 'Recipient'(TO) as an address in the same domain
(ie,<xxx>@<apeejaygroup.com>) it works fine.
But when I use an address such as <xxx>@<rediffmail.com>
the code gives an error like -
"javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
javax.mail.SendFailedException: 550 5.7.1 ... Relaying denied"
I am sending the piece of code for reference..
String host ="192.168.33.11";
String from="[email protected]";
String to="<xxx>@apeejaygroup.com";
( HERE USING THE ADDRESS AS <xxx>@<rediffmail>.com
GIVES THE EXCEPTION - javax.mail.SendFailedException: 550 5.7.1 ... Relaying denied )
Properties props = System.getProperties();
props.put("mail.smtp.host", host);
javax.mail.Session session1 = javax.mail.Session.getDefaultInstance
(props, null);
MimeMessage message = new MimeMessage(session1);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));
message.setSubject("Your Registration Details");
message.setContent(body,"text/html");
Transport.send(message);
Please help me out of this.
Regards
Satrajit

as you said that it might require authentication
but our mail server doesn't require authentication to mail.
Now what should i do ??Many servers are now authenticating by requiring you to fetch your e-mail before sending. This is basically because most SMTP mail servers CAN NOT authenticate in the normal sense of the word. So, they use the fetch process for authentication. The fetch process already requires authentication normally. Then your IP address will be good for, say, 20 minutes, and you can relay e-mail through the server.
It works with most E-mail clients such as Outlook or Netscape, because the default behavior is to 1.Connect to the POP server, 2.Login, 3.Download any new mail, 4.Connect to the SMTP server, 5.Upload any mail to send.
Even if you don't have any mail, your IP address will at least have been authenticated. Even if you just check for mail, and not download any, you should be OK.
So what I'd suggest is that you write some code that attempts to connect to your mail system's POP server, get authenticated successfully, then try sending out the e-mail through the SMTP server.

Similar Messages

  • Need to Send Mail from JSP...

    Dear Team,
    I Need to Send Mail from JSP, have Designed user Interface to enter
    to, from, subject, and message text .
    Have Downloaded mail.jar and activate.jar file..... and placed in tomcat lib directory and WEBAPPS/WEB-INF/lib Directory too
    How do i send a mail to user ?
    do I require something else apart from things that i have mentioned?
    do i have to Configure SMTP, POP3 or Something like this....
    Now If I Create a object of Type MimeMessage and Set Recipient, from, subject and if i say transport.send(message) will this do My JOB???

    Dear Team,
    I Need to Send Mail from JSP, have Designed user
    Interface to enter
    to, from, subject, and message text .
    Have Downloaded mail.jar and activate.jar file.....
    and placed in tomcat lib directory and
    d WEBAPPS/WEB-INF/lib Directory too
    How do i send a mail to user ?
    do I require something else apart from things that i
    have mentioned?
    do i have to Configure SMTP, POP3 or Something like
    this....
    Now If I Create a object of Type MimeMessage and Set
    Recipient, from, subject and if i say
    transport.send(message) will this do My JOB???Yup! in addition to all the above i need to know my mail box outgoing mail server. and that's enough...... i am able to do that.
    Regards,
    Jagadeesh HS.

  • How to send mail from jsp

    hi,
    i want to send mail from my jsp page.
    1) how can i do this
    2) do i need any mail server for doin this
    thanks
    regards
    manoj

    i want to send mail from my jsp page.
    1) how can i do this
    2) do i need any mail server for doin thisRead
    http://java.sun.com/developer/onlineTraining/JavaMail/
    Rather,
    try this:
    http://jakarta.apache.org/taglibs/doc/mailer-doc/mailer-1.1/index.html

  • Sending mail from JSP through Microsoft Outlook

    Hi all,
    i want to send an e-mail from JSP by clicking on link or button through Microsoft's Outlook..
    Can anyone guide me..

    something like this,
              try{
                   props = new Properties();
                   props.load(this.getClass().getClassLoader().getResourceAsStream("contact.properties"));
                   int i=0;
                   String referer = props.getProperty("contact.allow.referer."+i);
                   email = props.getProperty("report.email.error");
                   while(referer != null){
                        i++;
                        contact.put(referer, "true");
                        referer = props.getProperty("contact.allow.referer."+i);
              }catch(Exception e){
                   e.printStackTrace();
              try{
                   Session session = (Session)new InitialContext().lookup(this.props.getProperty("reports.jndi.email"));
                   SMTPMessage m = new SMTPMessage(session);
                   m.setFrom(InternetAddress.parse(this.props.getProperty("report.email.from"))[0]);
                   m.setRecipient(RecipientType.TO, new InternetAddress(this.email));
                   m.setSubject(this.getSub());
                   StringBuffer msg = new StringBuffer();
                   msg.append("Employee Name: "+fn + " " + ln +"\n");
                   msg.append("Employee ID: "+this.getId()+"\n");
                   msg.append("Message: "+this.getMsg()+"\n");
                   m.setText(msg.toString());
                   m.setReplyTo(InternetAddress.parse("no-reply"));
                   m.saveChanges();
                   Transport trans = session.getTransport();
                   trans.send(m);
                   trans.close();
              }catch(Exception e){
                   e.printStackTrace();
              }          contact.properties:
    reports.jndi.email=java:comp/env/globalMail
    report.generation.timeout=3000
    report.email.subject=Some Subject
    [email protected]
    [email protected]

  • Sending Mail from JSP-Servlet

    hi all,
    Can any one help me, how can i send the mail from JSP-Servlet.
    in Spring, we have a the following package to send mail,
    import org.springframework.mail.MailSender;
    import org.springframework.mail.SimpleMailMessage;
    import org.springframework.mail.javamail.JavaMailSenderImpl;
    Suggest me to solve the problem.
    Thanx in advance.
    Bala

    Hi balu,
    i already go thru that API. My problem is if i add any additional jar file for sending the mail from JSP or Servlets only. not in high technology.
    i mention spring as an example.
    so, kindly suggets me on that.
    Bala

  • Sending mail from JSP page with attachment

    I have a requirement to send mail with attachment from my jsp pages, which should come to a particular mail box. Can any one help me by sending sample codes. Thankx in advance.

    hi,
    When request is posted you have to save file data from request to a file. you can not access the data using request.getParameter("file").

  • Send mail from JSP page

    Hello,
    can some one help me to send emails from a jsp page.
    and if possible the source code of jsp or java...
    Thanks !

    read this:
    http://www.jspinsider.com/tutorials/jsp/javamail/jspjavamail_1.view

  • Sending mail from JSP page

    HI Everyone,
    Please help me out in this. It is very urgent so not able search the same in this forum.
    I have a J2EE application. The view is in JSP. If i click a button from a JSP page, any mail client (Microsoft Outlook) has to open and current page need to be attached as html. THen user wish to send the mail to somebody...
    So my aim is to open a outlook and attache the current JSP page as html. PLease help me out !

    Instead of outlook, you can do it easily using SMTP

  • How to send mail from jsp pageq

    Pls help me with this topic
    Thanks alot

    Can you make it clearer. Pls give me a sample code if possible
    Thanks alot

  • I want to send email from jsp,

    i want to send email from jsp, i dont know smtp:host, how to send mail?
    plz carify this doubt sir.

    OK thanks sir but i installed alredy. i write this code. plz send any error's are there. and i dont know smtp:host name. i put my port address?
    try{
        //Set the host smtp address
        Properties props = new Properties();
        props.put("mail.smtp.host", "//10/0/6/252");
        // create some properties and get the default Session
        Session session = Session.getDefaultInstance(props, null);
         // create a message
        Message msg = new MimeMessage(session);
        // set the from and to address
        msg.setFrom(new InternetAddress("[email protected]"));
         msg.addRecipient(Message.RecipientType.To,new InternetAddress("[email protected]"));
        // Setting the Subject and Content Type
        msg.setSubject("hi..");
        msg.setText("hi bharath how are you");
        Transport.send(msg);
    catch(Exception e)
                  out.println(e);
         }

  • How to send mail using jsp program

    am very new to jsp and doing my final year project. i need to send mails using my jsp program.can anyone say wht to do that is wht to include to send mails using jsp program. n also a sample code to send mail using jsp program.
    Thanx in advance

    Use below script.
    <%@ page import="java.util.*, javax.mail.*, javax.mail.internet.*" %>
    <%
    Properties props = new Properties();
    props.put("mail.smtp.host", "mailserver.com");
    Session s = Session.getInstance(props,null);
    InternetAddress from = new InternetAddress("[email protected]");
    InternetAddress to = new InternetAddress([email protected]");
    MimeMessage message = new MimeMessage(s);
    message.setFrom(from);
    message.addRecipient(Message.RecipientType.TO, to);
    message.setSubject("Your subject");
    message.setText("Your text");
    Transport.send(message);
    %>{code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to send Mail in JSP

    Hi,
    I am newbee in Java, I want to send mail to different accounts using java from my website. Plz help me with working example. I am new to java.
    Thanks in advance,
    devom

    Thanks, but I want to send mail from my WEb page that is in JSP. The arcticle pointed out sends mail in core java. I already know how to send in Core java, but i want to send through JSP. Plz help me.
    Thanks in advance,
    Devom

  • How to send mail from servlets

    m having troubles sending mail from servlets...
    how do you use the SimpleMailUser object needed in the session?
    a sample code on this would be of great help, thanks!

    <html>
    <body bgcolor="white">
    <font size=5 color="black">
    <%@ page import="javax.servlet.http.HttpUtils" %>
    <%@ page import="java.util.*" %>
    <%@ page import = "java.sql.*" %>
    <%@ page import = "java.io.*" %>
    <%@ page import= "sun.net.smtp.SmtpClient" %>
    <%
         String from,to,subject,msgbody,serverName;
         try
    from = request.getParameterValues("from")[0];
    to = request.getParameterValues("to")[0];
    subject = request.getParameterValues("subject")[0];
    msgbody = request.getParameterValues("msgbody")[0];
    serverName = request.getParameterValues("server")[0];
         catch (Exception e)          // Generally Speaking, an Error getting one of these
                                       // Values means that it wasnt passed in; inform the user
              out.println("You must call this JSP from this ");
              out.println("<A href=\"FormMail.htm\"> form</A>.<BR>");
              out.flush();return;
    %>
    Hold On A Moment while I try to Send Your Mail... <BR>
    <%
         out.flush();
         // Here are the real guts of the mail sending
         try
         sun.net.smtp.SmtpClient sm = new sun.net.smtp.SmtpClient(serverName);
         sm.from(from);
         sm.to(to);
         PrintStream msg = sm.startMessage();
         msg.println("To: ");     // Note dont use + for Performance
         msg.println(to);
         msg.println("Subject: ");
         msg.println(subject);
         msg.println();
         msg.println(msgbody);
         msg.println("==============");
         msg.print("This mail brought to you by JSP MAIL..from a user at IP ");
         msg.println(request.getRemoteHost());
         sm.closeServer();
         out.println("Your Mail Has Been Sent!");
         catch (Exception e)
              out.println("The mail couldn't be sent, probably because the mailhost wasnt set correctly.<BR> ");
              out.println("The error message I am getting is: ");
              out.println(e.getMessage());
    %>
    <BR>
    <BR>
    Click here to send another!

  • Sending mail from java program

    I want to send mail from my java program.
    does anyone have the sample code?

    http://forum.java.sun.com/thread.jsp?forum=31&thread=266116

  • Cannot send mail from mac mail or Entourage

    Hi guys,
    Wondered if anyone out there can shed some light on this little problem.
    I use Entourage for my emails & all was working fine until yesterday. I can receive mail from all and sundry but I can't send anything. I subscribe to ntlworld internet service and if log onto my email through their webmail, then it's fine. I've tried sending mail from mac mail and I get the same problem. I've been onto microsoft support & gone through all the troubleshooting with Entourage. The Entourage techy suggested it was my internet provider blocking my emails as they think I'm a spammer?? I phoned ntl & they insist it's nothing to do with them as I can send/receive from the website. (If I send an email with the address @ntlworld it's fine, but any other address i.e. all my clients/mates etc just stays in my outbox.
    Nothing on any of my settings has changed so I'm at a loss what to do next.
    Any suggestions greatly appreciated.
    Thanks, Mel

    it may be that your server (internet provider) has just started blocking outgoing mails not authenticated by them.
    Go to your account set up...
    and fill in the following details.
    SMTP SERVER: smtp.mac.com
    then click on advanced sending otions...
    click on override default SMTP port... type 587
    click on SMTP servber requires authentication...
    use same setting as receiving mail server.
    try this...

Maybe you are looking for

  • Problem with opening my current website in Muse

    Hi, I have a big problem with Muse. I can't open my current website. In fact, I have the following error message "Assert: "arrange Children:Very large bounds calculated for box with layout vertical". Could you please help me ? I'm using the new trial

  • Can't delete multiple selected items in List or Library

    I am experiencing quirky behavior when attempting to delete multiple selected items from a library or list. I select a few items via check box for each item I would like to delete. Then I click the delete button in the ribbon, and all I get is "Delet

  • Why can't I delete this audio clip or unlink it?

    Please see uploaded screenshot.  The soundtrack here is a continuous clip of music but I have snipped it to coincided exactly with the video clip above, and I've also snipped the Audio 1 clip at the same place.  There's nothing above, ie all other tr

  • Recording only creates one blank slide still the case. Please urgent help

    Hello, I am just beginner in activate recording. I record internet explorer screens or notepad . After recording END button,all records become one blank slide.  and No captions kept also for example I run the captivate 3 choose record new project cus

  • A program to test JVM

    Hi, I am looking for a small Java program that has all the [Java bytecodes|http://java.sun.com/docs/books/jvms/second_edition/html/Mnemonics.doc.html] used. In case any bytecode is not correctly implemented by a JVM then the program should returns fa