Mail in jsp

Hi,
i m using javamail in my project....
using local host i cud easily do it but i wanna use gmail as my ...
so can any one help me in doing it.....
i want simple code without using java beans...just in jsp n servlet
thank u in advance who ever helps me out....

m sorry to bother u again
there is again an error related to authentication
it says authentication failed
here is the code
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
response.setContentType("text/html");
PrintWriter out=response.getWriter();
String[] to={"[email protected]","[email protected]"};
String[] cc={"[email protected]","[email protected]"};
String[] bcc={"[email protected]"};
String userName="[email protected]";
String passWord="targethigh";
String host="smtp.gmail.com";
String port="465";
String starttls="true";
String auth="true";
boolean debug=true;
String socketFactoryClass="javax.net.ssl.SSLSocketFactory";
String fallback="false";
//String[] to=to;
String subject="hi there";
String text="this is testing mail";
Properties props = new Properties();
props.put("mail.smtp.user", userName);
props.put("mail.smtp.host", host);
          if(!"".equals(port))
props.put("mail.smtp.port", port);
          if(!"".equals(starttls))
props.put("mail.smtp.starttls.enable",starttls);
props.put("mail.smtp.auth", auth);
          if(debug){
     props.put("mail.smtp.debug", "true");
          }else{
     props.put("mail.smtp.debug", "false");          
          if(!"".equals(port))
props.put("mail.smtp.socketFactory.port", port);
          if(!"".equals(socketFactoryClass))
props.put("mail.smtp.socketFactory.class",socketFactoryClass);
          if(!"".equals(fallback))
props.put("mail.smtp.socketFactory.fallback", fallback);
try
Session session = Session.getDefaultInstance(props, null);
session.setDebug(debug);
MimeMessage msg = new MimeMessage(session);
msg.setText(text);
msg.setSubject(subject);
msg.setFrom(new InternetAddress("[email protected]"));
               for(int i=0;i<to.length;i++){
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
               for(int i=0;i<cc.length;i++){
msg.addRecipient(Message.RecipientType.CC, new InternetAddress(cc[i]));
               for(int i=0;i<bcc.length;i++){
msg.addRecipient(Message.RecipientType.BCC, new InternetAddress(bcc[i]));
msg.saveChanges();
               Transport transport = session.getTransport("smtp");
               transport.connect(host, userName, passWord);
               transport.sendMessage(msg, msg.getAllRecipients());
               transport.close();
out.println("message sent");
               //return true;
catch (MessagingException mex) {
mex.printStackTrace();

Similar Messages

  • 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 a Mail using JSP using browser.

    Dear friends
    I could write a code to send a mail and execute it from a command prompt using a class file, but the same code, I converted into a JSP tags to run from a browser. I am getting compilation error. Can you please help me in solving this problem.
    I am using javamail API 1.3,JAF1.0.2
    Win2000,Websphere 3.5,HostPublisher server 3.5,IE6.0
    I shall be thankful if someone shows me the solution.

    Hello
    I hope that this is useful
    I'm using Tomacat 4.0.4 and J2SDK1.4.0_01
    Setting on conf\Server.xml
    <Resource name="mail/Session" auth="Container"
                        type="javax.mail.Session"/>
              <ResourceParams name="mail/Session">
                <parameter>
                  <name>mail.smtp.host</name>
                  <value>your hostmail server</value>
                </parameter>
              </ResourceParams>Setting on web.inf/web.xml
    <servlet>
        <servlet-name>SendMailServlet</servlet-name>
        <servlet-class>SendMailServlet</servlet-class>
      </servlet>
    <servlet-mapping>
        <servlet-name>SendMailServlet</servlet-name>
        <url-pattern>/SendMailServlet</url-pattern>
      </servlet-mapping>
    <resource-ref>
        <res-ref-name>mail/Session</res-ref-name>
        <res-type>javax.mail.Session</res-type>
        <res-auth>Container</res-auth>
      </resource-ref>jsp page example:
    <html>
    <head>
    <title>Example Mail Sending Form</title>
    </head>
    <form method="POST" action="../../SendMailServlet">
    <table>
      <tr>
        <th align="center" colspan="2">
          Enter The Email Message To Be Sent
        </th>
      </tr>
      <tr>
        <th align="right">From:</th>
        <td align="left">
          <input type="text" name="mailfrom" size="60">
        </td>
      </tr>
      <tr>
        <th align="right">To:</th>
        <td align="left">
          <input type="text" name="mailto" size="60">
        </td>
      </tr>
      <tr>
        <th align="right">Subject:</th>
        <td align="left">
          <input type="text" name="mailsubject" size="60">
        </td>
      </tr>
      <tr>
        <td colspan="2">
          <textarea name="mailcontent" rows="10" cols="80">
          </textarea>
        </td>
      </tr>
      <tr>
        <td align="right">
          <input type="submit" value="Send">
        </td>
        <td align="left">
          <input type="reset" value="Reset">
        </td>
      </tr>
    </table>
    </form>
    </body>
    </html>SendMailServelet.java:
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.mail.Message;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeMessage;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.servlet.RequestDispatcher;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class SendMailServlet extends HttpServlet {
        public void doPost(HttpServletRequest request,
                           HttpServletResponse response)
            throws IOException, ServletException
            // Acquire request parameters we need
            String from = request.getParameter("mailfrom");
            String to = request.getParameter("mailto");
            String subject = request.getParameter("mailsubject");
            String content = request.getParameter("mailcontent");
            if ((from == null) || (to == null) ||
                (subject == null) || (content == null)) {
                RequestDispatcher rd =
                    getServletContext().getRequestDispatcher("/jsp/mail/sendmail.jsp");
                rd.forward(request, response);
                return;
            // Prepare the beginning of our response
            PrintWriter writer = response.getWriter();
            response.setContentType("text/html");
            writer.println("<html>");
            writer.println("<head>");
            writer.println("<title>Example Mail Sending Results</title>");
            writer.println("</head>");
            writer.println("<body bgcolor=\"white\">");
            try {
                // Acquire our JavaMail session object
                Context initCtx = new InitialContext();
                Context envCtx = (Context) initCtx.lookup("java:comp/env");
                Session session = (Session) envCtx.lookup("mail/Session");
                // Prepare our mail message
                Message message = new MimeMessage(session);
                message.setFrom(new InternetAddress(from));
                InternetAddress dests[] = new InternetAddress[]
                    { new InternetAddress(to) };
                message.setRecipients(Message.RecipientType.TO, dests);
                message.setSubject(subject);
                message.setContent(content, "text/plain");
                // Send our mail message
                Transport.send(message);
                // Report success
                writer.println("<strong>Message successfully sent!</strong>");
            } catch (Throwable t) {
                writer.println("<font color=\"red\">");
                writer.println("ENCOUNTERED EXCEPTION:  " + t);
                writer.println("<pre>");
                t.printStackTrace(writer);
                writer.println("</pre>");
                writer.println("</font>");
            // Prepare the ending of our response
            writer.println("<br><br>");
            writer.println("<a href=\"jsp/mail/sendmail.jsp\">Create a new message</a><br>");
            writer.println("</body>");
            writer.println("</html>");       
    }Ciao
    Riccardo

  • 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.

  • 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

  • How to send multiple attachments with the mail in jsp

    hi.I wrote a code to send mail.but i need to send mail with multiple attachments.when i run this code iam able to send message but not files.i want to send files as attachments with the message.please help me.
    <%@ page import="javax.mail.*,javax.mail.internet.*,java.util.Date,java.io.*,java.net.InetAddress,java.sql.*,java.util.Properties,java.net.*,javax.sql.*,javax.activation.*,java.util.*,java.text.*" %>
    <%@ page import="java.io.*,java.sql.*,java.net.*,java.util.*,java.text.*" %>
    <%
         String Attachfiles1="";
         String Attachfiles2="";
    String Attachfiles3="";
    if("Send".equalsIgnoreCase("send"))
    try
    String subject="",from="",url = null,to="";
    String mailhost = "localhost";
    Properties props = System.getProperties();
    String msg_txt="";
    String strStatus="";
    String mailer = "MyMailerProgram";
    to=request.getParameter("to");
    from=request.getParameter("from");
    subject=request.getParameter("subject");
    msg_txt=request.getParameter("message");
    props.put("mail.smtp.host", mailhost);
    Session mailsession = Session.getDefaultInstance(props, null);
    Message message = new MimeMessage(mailsession);
    message.setFrom(new InternetAddress(from));
    message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to, false));
    message.setSubject(subject);
    message.setHeader("X-Mailer", mailer);
    message.setSentDate(new Date());
    message.setText(msg_txt);
    BodyPart messageBodyPart = new MimeBodyPart();
    BodyPart messageBodyPart2 = new MimeBodyPart();
    Multipart multipart = new MimeMultipart(); // to add many part to your messge
    messageBodyPart = new MimeBodyPart();
    javax.activation.DataSource source = new javax.activation.FileDataSource("path of the file");
    messageBodyPart.setDataHandler(new DataHandler(source));
    messageBodyPart.setFileName("file_name");
    messageBodyPart2.setText("message"); // set the txt message
    multipart.addBodyPart(messageBodyPart);
    multipart.addBodyPart(messageBodyPart2);
    Transport.send(message);
    out.println("Message Sent");
    catch (Exception e)
    e.printStackTrace();
    if("Attachfiles".equalsIgnoreCase("attachfiles"))
    Attachfiles1=request.getParameter("fieldname1");
    Attachfiles2=request.getParameter("fieldname2");
    Attachfiles3=request.getParameter("fieldname3");
    %>
    <html>
    <body>
    <div class="frame">
    <form action="Composemail.jsp" method="post">
    <b>SelectPosition:</b> <select name="cars" >
    <option value="ABAP">ABAP
    <option value="saab">Saab
    <option value="fiat">Fiat
    <option value="audi">Audi
    </select><br><br>
    <table border="1" cellpadding="2" cellspacing="2">
    <tr><th>Name</th>
    <th>EmailId</th>
    <th>ContactNumber</th>
    <th>Position</th>
    </tr>
    <tr>
    <td>
    </td>
    </tr>
    </table><br>
    <b>SelectUser :</b><select name="cars">
    <option value="Administrator">Administrator
    <option value="saab">Saab
    <option value="fiat">Fiat
    <option value="audi">Audi
    </select>
    <br>
    <b>To :</b>�����������<input type="text" name="to" size="72"><br>
    <b>From :</b>�������<input type="text" name="from" size="72"><br>
    <b>Subject :</b>���<input type="text" name="subject" size="72"><br>
    <%=Attachfiles1%><br><%=Attachfiles2%><br><%=Attachfiles3%><br><br>
    <b>Message:</b><br>
    ������������<textarea rows="10" cols="50" name="message">
    </textarea> <br><br>
    <b>AttachedFile:</b>�<input type="file" name="fieldname1" value="filename" size="50"><br><br>
    <b>AttachedFile:</b>�<input type="file" name="fieldname2" value="filename" size="50"><br><br>
    <b>AttachedFile:</b>�<input type="file" name="fieldname3" value="filename" size="50"><br><br>
    ������������<input type="submit" name="attachfiles" value="Attachfiles">
    <center>
    <input type="submit" name="send" value="Send" >
    </center>
    </form>
    </div>
    </body>
    </html>

    Most likely you're not specifying the path of a file on the server machine.

  • How to send E-mails using JSP

    I developed a system where users can login and check for updated information and documents. But the changes are made once or twice in a year. I want to send email after changing the documents. I stored email addresses in the DB. Now the question is how to send e-mails to concerned users without using external software (Outlook, etc.). [Considering same subject and message for all e-mails.]

    Go to Java Mail forum:
    http://forum.java.sun.com/forum.jsp?forum=43

  • How to attach a file to the mail in jsp

    hi.i would like to send mails with in local server with files as attachments.i wrote this code but its not working.please help
    <%@ page import="javax.mail.*,javax.mail.internet.*,java.util.Date,java.io.*,java.net.InetAddress,java.sql.*,java.util.Properties,java.net.*,javax.sql.*,javax.activation.*,java.util.*,java.text.*" %>
    <%@ page import="java.io.*,java.sql.*,java.net.*,java.util.*,java.text.*" %>
    <%
         String Attachfiles1="";
    if("Send".equalsIgnoreCase("send"))
    try
         String subject="",from="",url = null,to="";
         String mailhost = "local server";
         Properties props = System.getProperties();
    String msg_txt="";
         String strStatus="";
    String mailer = "MyMailerProgram";
    to=request.getParameter("to");
    from=request.getParameter("from");
    subject=request.getParameter("subject");
    msg_txt=request.getParameter("message");
    Attachfiles1=request.getParameter("fieldname1");
    props.put("mail.smtp.host", mailhost);
    Session mailsession = Session.getDefaultInstance(props, null);
    Message message = new MimeMessage(mailsession);
    message.setFrom(new InternetAddress(from));
    message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to, false));
    // message.setSubject(subject);
    // message.setHeader("X-Mailer", mailer);
    // message.setSentDate(new Date());
    message.setText(msg_txt);
                   // Final message = part1 + part2
                   Multipart mp = new MimeMultipart();
                   message.setContent(mp);
                   // Message part 1 is text - add to multipart
                   MimeBodyPart m1 = new MimeBodyPart();
                   m1.setContent(msg_txt, "text/plain");
                   mp.addBodyPart(m1);
                   // Message part 2 is binary (file to send)
                   MimeBodyPart m2;
                   // Support multiple file send (separated by ";")
                   FileDataSource fds = new FileDataSource(Attachfiles1);
                        m2 = new MimeBodyPart();
                        m2.setDataHandler(new DataHandler(fds) );
                        m2.setFileName( new File(Attachfiles1).getName() );
                        mp.addBodyPart(m2);     // add to final message (part 2)
    //message.addAttachment(new Attachment(new File(Attachfiles1)));
    //BodyPart messageBodyPart = new MimeBodyPart();
    //BodyPart messageBodyPart2 = new MimeBodyPart();
    //Multipart multipart = new MimeMultipart();
    ////messageBodyPart = new MimeBodyPart();
    //javax.activation.DataSource source = new javax.activation.FileDataSource(Attachfiles1);
    //messageBodyPart.setDataHandler(new DataHandler(source));
    ////messageBodyPart.setFileName(new File(Attachfiles1).getName());
    //messageBodyPart2.setText(msg_txt); // set the txt message
    //multipart.addBodyPart(messageBodyPart);
    //multipart.addBodyPart(messageBodyPart2);
    //message.setContent(this.multipart);
    Transport.send(message);
    out.println("Message Sent");
    catch (Exception e)
    e.printStackTrace();
    %>
    <html>
    <body>
    <div class="frame">
         <form action="Composemailpp.jsp" method="post">
              <b>SelectPosition:</b> <select name="cars" >
    <option value="ABAP">ABAP
    <option value="JAVA">JAVA
    <option value="DOTNET">DOTNET
    <option value="SAP">SAP
    </select><br><br>
    <table border="1" cellpadding="2" cellspacing="2">
    <tr><th>
    Name<br><input type="text" name="Name"><br>
    </th>
    <th>
    EmailId<br><input type="text" name="EmailId"><br>
    </th>
    <th>
    ContactNumber<br><input type="text" name="ContactNumber"><br>
    </th>
    <th>
    Position<br><input type="text" name="Position"><br>
    </th>
    </tr>
    </table><br>
    <b>SelectUser :</b><select name="cars">
    <option value="Administrator">Administrator
    <option value="User1">User1
    <option value="User2">User2
    <option value="User3">User3
    <option value="User3">User4
    </select>
    <br>
    <b>To :</b>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<input type="text" name="to" size="72"><br>
    <b>From :</b>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<input type="text" name="from" size="72"><br>
    <b>Subject :</b>&nbsp&nbsp&nbsp<input type="text" name="subject" size="72"><br>
    <b>Message:</b><br>
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<textarea rows="10" cols="50" name="message">
    </textarea> <br><br>
    <b>AttachedFile:</b>&nbsp<input type="file" name="fieldname1" value="filename" size="50"><br><br>
    <!--<b>AttachedFile:</b>&nbsp<input type="file" name="fieldname2" value="filename" size="50"><br><br>
    <b>AttachedFile:</b>&nbsp<input type="file" name="fieldname3" value="filename" size="50"><br><br>
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<input type="submit" name="attachfiles" value="Attachfiles">
    -->
    <center>
    <input type="submit" name="send" value="Send" >
    </center>
    </form>
    </div>
    </body>
    </html>

    message.setText(msg_txt);Don't do this. You want a multipart message. You want the msg_txt
    to be the first part of the multipart, which you do below.
                   // Final message = part1 + part2
                   Multipart mp = new MimeMultipart();
                   message.setContent(mp);
                   // Message part 1 is text - add to multipart
                   MimeBodyPart m1 = new MimeBodyPart();
                   m1.setContent(msg_txt, "text/plain");m1.setText(msg_txt); // would be better
                   mp.addBodyPart(m1);
                   // Message part 2 is binary (file to send)
                   MimeBodyPart m2;
                   // Support multiple file send (separated by ";")
    FileDataSource fds = new
    new FileDataSource(Attachfiles1);
                        m2 = new MimeBodyPart();
                        m2.setDataHandler(new DataHandler(fds) );
    m2.setFileName( new File(Attachfiles1).getName() );Since you're using JavaMail 1.4, you can replace much of the above
    with simply:
    m2.attachFile(Attachfiles1);
    But none of the problems above should prevent your code from working.
    You do understand, of course, that the name of the file is a filename
    on the server, not the client that's running the browser, right?
    When you say "its not working", what exactly do you mean?

  • Error sending mail via JSP in weblogic 5.1

    Hi,
    I am running weblogic 5.1. I am trying to send an email via a JSP page and I get
    the following error in the browser:
    Error 500--Internal Server Error
    From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
    10.5.1 500 Internal Server Error
    The server encountered an unexpected condition which prevented it from fulfilling
    the request.
    and the following error in the weblogic command console:
    Fri Oct 18 18:25:17 EDT 2002:<E> <ServletContext-General> Servlet failed with
    Exception
    java.lang.NoClassDefFoundError: javax/mail/Message
    at jsp_servlet._jmail._jspService(_jmail.java:91)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:120)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:138)
    at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:915)
    at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:879)
    at weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContextManager.java:269)
    at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:365)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:253)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129).
    I am using a jsp page and a bean in that. Bean has the java mail code.
    If I put the same code in a JSP page instead of a bean, it is working fine.
    I take the same code files to another instance on weblogic, I dont get any errors.
    Any help will be greatly appreciated.
    Thanx
    Raju

    how is the weblogic.properties configured?
    how do you run the BWLS ? memory (M)?
    is the documentroot and the WEBLOGIC JSP PROPERTIES right ?

  • Java mail and jsp -HELP!! HELP!!

    Hi all
    I have a simple email module with a jsp page and a html page I am trying to connect to a yahoo smtp server and send a mail from the webpage to the smtp server - I am getting an Authentication required error.
    error ##
    org.apache.jasper.JasperException: Sending failed;
    nested exception is:
         class javax.mail.MessagingException: 530 authentication required - for help go to http://help.yahoo.com/help/us/sbc/dsl/mail/pop/pop-11.html
    Can anyonne tell me how to use a simple smtp email facility
    how to use an authenticator in the jsp
    ciao
    laodingdockjavaguy

    It's required that you authentificate yourself at the smpt server
    The following snipplet sends a msg using the smtp protocol.
    Transport tr = session.getTransport("smtp");
    tr.connect(smtphost, username, password);
    msg.saveChanges();     // don't forget this
    tr.sendMessage(msg, msg.getAllRecipients());
    tr.close();If this still fails You can also try to set the property mail.smtp.auth to true.
    mail.smtp.auth      boolean      If true, attempt to authenticate the user using the AUTH command. Defaults to false.see also http://java.sun.com/products/javamail/1.3/docs/javadocs/com/sun/mail/smtp/package-summary.html
    for a complete description of the properties supported by the smpt transport.
    hope it helps

  • 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 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

    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.

  • Problem in sending mail using Jsp(Jdeveloper9i)

    My Code is working when i m sending mail through commandpromt
    c:/Jdeveloper/Jdk/bin
    But when I m trying it thjrough jsp page than it gives compilation error that not found
    Javax.mail.* and Javax.mail.internet.*
    I have tried to add mail.jar and activation.jar in c:/Jdeveloper/jdev/jre/lib/ext
    If it is wrong place to add these files than plz suggest what i have to do.
    Thanks in Advance

    This is just a relay error. This means that the outbound SMTP server you are using doesn't allow relaying.
    Relaying is where the sender is not part of the domain the SMTP server manages. The no-relay concept is pretty common now as spammers often use SMTP servers which allow relaying to send their spam.
    The solution is to allow relaying on the SMTP server for your IP address. Another solution which some SMTP servers will implement is to allow relaying for clients who successfully authenticate regardless of their IP address. This is sometimes a better solution because it means you don't have to change anything if your client code moves to a different server.
    In your error message:
    class javax.mail.SendFailedException: 551 User not local. We don't relay
    You can see the SMTP Error Code (551). Look at the SMTP specification (rfc 821 I think) to see what all the error codes mean in case you get another one

Maybe you are looking for

  • Printing in white ink.

    I know you can't print white using black and color cartridges, I get that, so let's not rehash what everyone already knows... the question is quite simple - has HP ever made a cartridge with WHITE ink to replace black ink cartridges? I'd like to prin

  • No audio when using latest version of quicktime for some files

    I have some .mov files that play perfectly using Quicktime 4 (included with the cd containing the files, old lectures from 2000). Now, I have the newest version of quicktime and the video plays with no problems, but I get no audio. I uninstalled the

  • Can I control read authorizations of roadmap per each nodes?

    Hello, everyone. My customer has requested me to restrict read authorization of roadmap. We use one roadmap and one project. He want to restrict read authorizations of several nodes and let some managers can read documents of the nodes. But he don't

  • How do I get videos to play in the browser?

    I get sound when I try to play a video in the browser, but I don't get any video playback. A lot of the time, I just get a spinning circle or whatever "processing/wait" icon the video player uses. I am running FF 33 for Android on an LG Optimus G Pro

  • Unable to remove rogue podcasts from iTunes library

    Hi, I've recently imported some mp3 files into my iTunes library. The files were tagged as podcasts but after I imported them they didn't show up in either my music or podcasts libraries. The only place I could see the files in iTunes was in any smar