How to send mail in servlet witout relying...

Hii,
I some cicumstances I have to send a mail to my user that contains some information ..
anyway..
As far as I seen from the example codes They are all using relying technique to send mail via server.. but I couldnt found any smtp server to relying.. so I get
Invalid Addresses;
nested exception is:
     class com.sun.mail.smtp.SMTPAddressFailedException: 553 sorry, relaying denied from your location [myIp] (#5.7.1)
exception....
We have a smtp server which is closed for relying.. but I dont know how to log on this server and send mail via our server..
this is my send method..
try
          Properties props = System.getProperties();
          // -- Attaching to default Session, or we could start a new one --
          props.put("SERVER", "SERVER");
          Session session = Session.getDefaultInstance(props, null);
          // -- Create a new message --
          Message msg = new MimeMessage(session);
          // -- Set the FROM and TO fields --
          msg.setFrom(new InternetAddress(from));
          msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to, false));
          // -- We could include CC recipients too --
          // if (cc != null)
          // msg.setRecipients(Message.RecipientType.CC
          // ,InternetAddress.parse(cc, false));
          // -- Set the subject and body text --
          msg.setSubject(tosend.getSubject());
          msg.setText(tosend.getBody());
          // -- Set some other header information --
          msg.setHeader("X-Mailer", "LOTONtechEmail");
          msg.setSentDate(new Date());
          // -- Send the message --
          Transport.send(msg);
          send = true;
          catch (Exception ex)
               out.append("Thats the reason "+ex.getMessage());
               out.close();
          out.append("Done ? "+send);
          out.close();
          return send;
which modification should I make to authoriza with username/password....
thanks..

We have a smtp server which is closed for relying.. but I dont know how to log on this server and send mail via our server.. Who is this "we"? If it's a company you work for, then the server will have an administrator. Go and talk to that person.

Similar Messages

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

  • How can send mails using hotmail/rediffmail domain name?

    I have used the below code to send a mail using javamail API?Even when I am sending my application does not have notified any of error/exceptions,But the message is not reached to I have given receipient's address in the to field.
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    public class Sendmail1 extends HttpServlet {
    private String smtpHost;
    // Initialize the servlet with the hostname of the SMTP server
    // we'll be using the send the messages
    public void init(ServletConfig config)
    throws ServletException {
    super.init(config);
    smtpHost = config.getInitParameter("smtpHost");
    //smtpHost = "sbm5501";
    smtpHost = "www.rediffmail.com";
    public void doGet(HttpServletRequest request,HttpServletResponse response)
    throws ServletException, java.io.IOException {
    String from = request.getParameter("from");
    String to "[email protected]";
    String cc = "[email protected]";
    String bcc ="[email protected]";
    String smtp ="www.rediffmail.com";
    String subject = "hai";
    String text = "Hai how r u";
    PrintWriter writer = response.getWriter();
    if (subject == null)
    subject = "Null";
    if (text == null)
    text = "No message";
    String status;
    try {
    // Create the JavaMail session
    java.util.Properties properties = System.getProperties();
    if (smtp == null)
    smtp = "www.rediffmail.com";
    properties.put("mail.smtp.host", smtp);
    Session session = Session.getInstance(properties, null);
    //to connect
    //Transport transport =session.getTransport("smtp");
    //transport.connect(smtpHost,user,password);
    // Construct the message
    MimeMessage message = new MimeMessage(session);
    // Set the from address
    Address fromAddress = new InternetAddress(from);
    message.setFrom(fromAddress);
    // Parse and set the recipient addresses
    Address[] toAddresses = InternetAddress.parse(to);
    message.setRecipients(Message.RecipientType.TO,toAddresses);
    Address[] ccAddresses = InternetAddress.parse(cc);
    message.setRecipients(Message.RecipientType.CC,ccAddresses);
    Address[] bccAddresses = InternetAddress.parse(to);
    message.setRecipients(Message.RecipientType.BCC,bccAddresses);
    // Set the subject and text
    message.setSubject(subject);
    message.setText(text);
    Transport.send(message);
    //status = "<h1>Congratulations,</h1><h2>Your message was sent.</h2>";
    } catch (AddressException e)
    status = "There was an error parsing the addresses. " + e;
    } catch (SendFailedException e)
    status = "<h1>Sorry,</h1><h2>There was an error sending the message.</h2>" + e;
    } catch (MessagingException e)
    status = "There was an unexpected error. " + e;
    // Output a status message
    response.setContentType("text/html");
    writer.println("<title>sendForm</title><body bgcolor= ><b><h3><font color=green><CENTER>CALIBERINFO.COM</CENTER></h3>Your message was sent to recepient(s).<br><font color=red>"+"\n"+to);
    writer.println("<br><br><a href=e:/mail/javamail/mail.html>back to compose</a>");
    writer.close();
    Please any one help me out from this probs.
    Awaiting for yours reply,
    or give me a reply to: [email protected]
    Regards,
    @maheshkumar.k

    Hi,
    how can send mails using hotmail/rediffmail domain name?In your java application,you specified www.rediffmail.com as your
    smtp server.But that is the address of that website.Try will a smtp
    server instead.For a list of free smtp servers,please visit http://www.thebestfree.net/free/freesmtp.htm
    Hope this helps.
    Good Luck.
    Gayam.Srinivasa Reddy
    Developer Technical Support
    Sun Microsystems
    http://www.sun.com/developers/support/

  • How to send mail to distribution list ?

    Hi Everybody,
    Pls let me know how to send mail to distributed list???
    Thanks & Regards,
    raju<b></b>

    Hi ,
      Use Function Module 'SO_NEW_DOCUMENT_SEND_API1'.
      U need to pass Distribution list to Receiver and 'C' to receiver type refer the below code for clarification.
    Determine the Distribution List.
            gv_rec_list-receiver = gv_distribution.
            gv_rec_list-rec_type = 'C'.
            APPEND gv_rec_list.
    Check if Distribution List is deleted.
            SELECT SINGLE objnam
                     FROM soid
                     INTO lc_objnam
                     WHERE objnam = gv_rec_list AND
                           dlitp  = lc_dli.
            IF sy-subrc = 0.
              CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
                EXPORTING
                  document_data              = gv_doc_data
                  document_type              = 'RAW'
                  put_in_outbox              = 'X'
                TABLES
                  object_content             = gv_obj_cont
                  receivers                  = gv_rec_list
                EXCEPTIONS
                  too_many_receivers         = 1
                  document_not_sent          = 2
                  document_type_not_exist    = 3
                  operation_no_authorization = 4.
              CASE sy-subrc.
                WHEN '1'.
                 message i001(as) with 'TOO MANY RECEIVERS'.
                  EXIT.
                WHEN '2'.
                 message i001(as) with 'DOCUMENT NOT SENT'.
                  EXIT.
                WHEN '3'.
                 message i001(as) with 'DOCUMENT TYPE DOES NOT EXIST'.
                  EXIT.
                WHEN '4'.
                 message i001(as) with 'OPERATION NO AUTHORIZATION'.
                  EXIT.
              ENDCASE.
              Hope this might have helped you.
    Thanks,
    Prashanth

  • How to send mail in html format in jsp???

    Hello everybody,
    I have two jsp pages.In one page I have the heading like Date,Transaction.I am retriving data from my second jsp page.And I hae included the second jsp page to my first jsp page.How to send mail this content in html format.
    Thanks
    Srikant

    MimeMessage m = new MimeMessage(session);
    BodyPart messageBodyPart = new MimeBodyPart();
    messageBodyPart.setContent(content, "text/html");this if u need to send a mail content as html

  • How to send mail with attachment

    Hi,
    How to send mail with word document as attachment in oracle pl/sql.
    kindly help me .
    thank you
    regards
    P Prakash

    create or replace procedure pdf_mail(
        p_sender     varchar2, -- sender, example: 'Me <[email protected]>'
        p_recipients varchar2, -- recipients, example: 'Someone <[email protected]>'
        p_subject    varchar2, -- subject
    p_text   varchar2, -- text
    p_filename  varchar2, -- name of pdf file
    p_blob   blob     -- pdf file
    ) is
      conn      utl_smtp.connection;
      i number;
      len number;
    BEGIN
      conn := demo_mail.begin_mail(
        sender     => p_sender,
        recipients => p_recipients,
        subject    => p_subject,
        mime_type  => demo_mail.MULTIPART_MIME_TYPE);
      demo_mail.begin_attachment(
        conn         => conn,
        mime_type    => 'application/pdf',
        inline       => TRUE,
        filename     => p_filename,
        transfer_enc => 'base64');
        -- split the Base64 encoded attachment into multiple lines
       i   := 1;
       len := DBMS_LOB.getLength(p_blob);
       WHILE (i < len) LOOP
          IF(i + demo_mail.MAX_BASE64_LINE_WIDTH < len)THEN
             UTL_SMTP.Write_Raw_Data (conn
                                    , UTL_ENCODE.Base64_Encode(
                                            DBMS_LOB.Substr(p_blob, demo_mail.MAX_BASE64_LINE_WIDTH, i)));
          ELSE
             UTL_SMTP.Write_Raw_Data (conn
                                    , UTL_ENCODE.Base64_Encode(
                                            DBMS_LOB.Substr(p_blob, (len - i)+1,  i)));
          END IF;
          UTL_SMTP.Write_Data(conn, UTL_TCP.CRLF);
          i := i + demo_mail.MAX_BASE64_LINE_WIDTH;
       END LOOP;
      demo_mail.end_attachment(conn => conn);
      demo_mail.attach_text(
        conn      => conn,
        data      => p_text,
        mime_type => 'text/html');
      demo_mail.end_mail( conn => conn );
    END;
    ref:
    http://www.plpdf.com/23-1725.html
    Edited by: Mahanam on Jan 9, 2011 10:32 PM

  • How to send mail in APEX 4.1 using PLSQL

    Hi All,
    How to send mail in APEX 4.1 using PLSQL?
    Thanks In advance.
    Regards
    Shail

    http://lmgtfy.com/?q=oracle+apex+4.1+send+mail

  • How to Send mail in oracle 10g

    I am new in oracle developer.....we are using oracle 10g developer...how to send mail through oracle 10g on a button click.pease help me.
    Thanks in advance

    This question have been asked many times on this forum, see if you get help from following:
    https://forums.oracle.com/message/5395438#5395438
    Search results: https://forums.oracle.com/thread/search.jspa?peopleEnabled=true&userID=&containerType=&container=&q=form+email
    Check this out as well:
    http://nzchaudhry.wordpress.com/2013/05/31/send-report-via-email-attachment-in-oracle-forms-10g/
    You can find init.ora or initSID.ora file under $ORACLE_HOME/dbs on linux and on Windows under $ORACLE_HOME/database. Otherwise you can create it using "create pfile from spfile" command
    Aneel

  • How to send Vector to Servlet?

    hi~~
    i want know that method of communicate form applet to Servlet.
    So far as I am concerned, Applet can't use I/O because of security.. but it can communicate with Servlet of calling the Applet.
    then, for example Vector.... How can send Vector to Servlet..

    The same way you send anything to a servlet, and the same way you send a vector to anywhere! You can do it a few ways, here's the one you'll see most of the time:
    URL servletURL = new URL(getDocumentBase(), "/servlet/myServlet");
    // Hope it's HTTP.  You probably should use instanceof before casting here.
    HttpURLConnection conn = (HttpURLConnection)servletURL.openConnection();
    conn.setDoOutput(true);
    ObjectOutputStream out = new ObjectOutputStream(conn.getOutputStream());
    out.writeObject(myVector);

  • Please help, how to send mails faster / send more mails per hour

    hello,
    in my application i am using mail sender class i have created to send mail to the users to participate in a survey. following is the code for it. i would like to know if there is anything wrong in it coz it takes to much time to send the mails it is taking 2 minustes to send 6 mails i.e 360 mails per hour only.
    following is how i instantiate the mail sender class and then generate a http link string dynamically as it is different for all the user.
    //////////class where mail sender is instantiated////////////////////
    try
    setConnection();
    st=con.createStatement();
    rs=st.executeQuery("select * from "+CNAME+"_campaign");                         
    String SurveyT = new String();
    while(rs.next())
         SurveyT = rs.getString(2);
    rs.close();
    rs=st.executeQuery("select * from "+CNAME+"_user");     
    ss = new MailSender();
    while(rs.next())
         String userid = rs.getString("userid");
         String password = rs.getString("password");
    StringBuffer message = new StringBuffer(BodyText.getText().trim());
    if(SurveyT.equals("invitational") || SurveyT.equals("single"))
                                            message.append( "\n" + "http://"+IPadd.getText().trim()+"/"+CNAME+"/servlet/login?username="+userid+"&passw="+password);
                                            ss.send(FromField.getText().trim(),userid,SmtpServerID.getText().trim(),MailSub.getText().trim(),message.toString());
    else if(SurveyT.equals("general"))
    message.append( "\n" + "http://"+IPadd.getText().trim()+"/"+CNAME+"/Index.html");
    ss.send(FromField.getText().trim(),userid,SmtpServerID.getText().trim(),MailSub.getText().trim(),message.toString());
    st.close();
    this.dispose();
    catch(SQLException sqlex)
    JOptionPane.showMessageDialog(null,sqlex.getMessage());
    //Mail Sender class/////////////////
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    import javax.swing.*;
    public class MailSender
         String sentAddr,fromAddr,smtpServer,body,subject;
         public MailSender()
         //function send to send the mail
    public void send(String from,String to,String smtps,String subj,String messagetext)
              fromAddr=new String(from);
              sentAddr=new String(to);
              smtpServer=new String(smtps);
              body=new String(messagetext);
              subject=new String(subj);
              try
                   Properties props = System.getProperties();
                   props.put("mail.smtp.host",smtpServer);
         Session session = Session.getDefaultInstance(props,null);
    Message msg = new MimeMessage(session);
                   msg.setFrom(new InternetAddress(fromAddr));
    msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(sentAddr,false));
         msg.setSubject(subject);
         msg.setText(body);
    msg.setHeader("Survey","MailCheck");
    msg.setSentDate(new Date());
         Transport.send(msg);
         catch(MessagingException mex)
              JOptionPane.showMessageDialog(null,mex.getMessage());
    }

    Lots of variables here....Also my maths says only 180 per hour.... i.e. three a minute.
    1) you are using a database to get info from. What is the average response time of the DB server? Looks like you are doing one SQL then reading the result table but does the initial SQL take a while?
    2) how much data are you passing on to the SMTP server and how fast/slow is the link to that SMTP server? Work out the absolute max amount of data you can transfer over the link then get your average message size and work out a VERY theoretical Max number of messages a minute. Note that real life might approach 80% of this taking TCP/IP and SMTP overheads into account.
    3) What sort of load is the SMTP server under? If it's busy you will be only getting a fraction of whatever bandwidth is available. Depending on its design it may be trying to deliver the first message you sent it while you are still pumping more messages down to it. SMTP servers may limit the number of connections per minute from another machine in order to defeat a denial of service attack. Your code makes a connection per email so this may have relevence here.
    4) Raw horsepower always helps. When I write stuff to do things like this there is no nice GUI screen etc. Just basic Java that if it has to will write a log if something goes wrong. Maybe just maybe a counter on STD out to show it is still actually doing something. Keep the number of classes used down to the bare minimum. In the old days we used to spend days paring code to the bone - a skill somewhat lost these days.
    Hope this gives you some help in finding the bottleneck.
    Cheers,
    SH

  • Please help me to use javamail to send mail in servlet program

    hi
    i want to send simple mail from user [email protected] to user [email protected] using servlet program
    i can't compile the javamail demo program servlet "JavaMailServlet.java".
    i have this exception
    Note: SendMailServlet.java uses or overrides a deprecated API.
    Note: Recompile with -deprecation for details.
    i don't no how to do
    please help me if you have code
    thank's

    Given that you're having problems with your [url http://forum.java.sun.com/thread.jsp?forum=43&thread=536278&tstart=0&trange=30]demo mail code as well as your demo servlet code, perhaps you would be better served by learning about JavaMail, servlets, and perhaps Java in general (for example - the meaning of deprecated). Then you may be able to build your own servlet for handling mail or at least will be able to revise the demo code found elsewhere.
    Of course, if the purpose is really not to learn how to use Java, JavaMail, servlets, etc. but to simply create something that works then you could always hire someone to write the program for you.
    This is not intended to be rude or anything - just an observation and some food for thought.
    &#8734; brewman &#8734;

  • How to send Mail in case of Output Determination - Transmission medium 5

    Dear Friends,
    I have a below requirement.
    - Create custom output type having Transmission medium 5, which triggers on creation of order.
    - Write driver program attached to that output type that sends e-mail to the person who has created the order.
    - Mail contain information regarding pricing for individual line item wise.
    I have gone through many posts but not sure about process of generate the mail in case of Transmission medium 5.
    My query is:
    Do we require to write FM (SO_NEW_DOCUMENT_ATT_SEND_API1) to send e-mail to respective person or it will take care by system (Transmission medium 5)?
    If FM not required then how can we write code that triggers the mail to specific mail ID?
    Nilay

    Yes, for your custom requirement you will have to create a Z report.
    LIke your requirement must be to put something specific in mail body or attach something with mail. All this will not be catered by the standard report maintained against your output type and transmission medium.
    As i understand for any output type a message is triggerd and stored in database table (like NAST) and then these requests are picked by standard report (like RSNAST00). These reports then in return call the Program/form maintained against the ouptut type and transmission medium (table TNAPR).
    So i would suggest that create a custom report and use the FM for sending mails. These FMs are pretty simple to use. Find a sample code in the below link:
    [http://wiki.sdn.sap.com/wiki/display/ABAP/SendExternalMailwithattachment]

  • How to send mail as a distribution list

    I have created a number of distribution lists under the groups tab just to the right of mailboxes in the recipients section of the exchange admin centre in microsoft exchange 2013.
    i have set permission on these mailboxes for send as to be permitted but when trying to send mail from outlook 2013, outlook web app or from ios i am unable to get the distribution lists email address to appear in the from list.
    could someone please explain how i can resolve this for each of these 3 platforms?

    Hi,
    Great advice from Veerapandian.
    Based on my knowledge, Distribution List is based on Outlook, Distribution Group is based on Exchange server. You can grand send as permission to DG.
    Send as permission is a permission based on AD, please make sure the DG can be resolved from GAL.
    Please run following command to whether set “Hide this group from address lists” attribution, if so please remove this setting.
    Get-DistributionGroup | FL alias,*HiddenFromAddressListsEnabled*
    More details about Configure Distribution Group Properties, please refer to:
    http://technet.microsoft.com/en-us/library/bb124513(v=exchg.150).aspx
    Best Regards,
    Allen Wang

  • How to send mail to distribution list and another table list

    Hi
    I am facing a problem. I need to send mail to the user who is creating the SO/PO and a distribution list.
    Problem is only one thing can be used at the same time. ie either Distribution list or list from internal table.
    How can we use both in 1 function module. Like it should call the internal table and then the distribution list for sending the mail .
    Regards,
    Varun

    Hi,
    Refer to following link,
    http://www.sap-img.com/abap/make-e-mail-sender-of-po-the-po-creators-name.htm
    http://www.sap-img.com/fu016.htm
    Reward pts. if helpfull.
    Regards,
    Dhan

  • HOW TO Send mail while saving VA02

    How can i send mail while saving VA02.
    The mail address i have to pick from custom table based on plant.
    Just for the trial we used : output type :KRML
    Application : V1
    Transaction medium :7.
    and the program RSNASTSO routine SAPOFFICE_AUFRUF_VX is attached in the nace.
    The same output type is attached in va02.If we use this output type with this medium , it is asking us mail partner
    address also in the VA02.
    but we have to get the mail partner from custom table.
    And with this output type , the program attched in the NACE (RSNASTSO) IS NOT GETTING triggered.
    But the mail is being sent to the mail partner which i mentioned in the VA02 Communication method.
    How can i solve this.
    Finally my requirement is i have to send a mail to exter id which is maintained in the custom table while saving VA02.
    Regards
    Ramakrishna L

    Hi,
    We had set a output type in NACE. and that output type we have in the VA02 transaction also.
    But While saving the transaction it is not going through the program mentioned in the NACE for that output type.
    But mail is sent to the SAP Inbox or official id .
    how that mail is gone i am not understanding.
    How can we do to go through the program mentioned in NACE while saving the VA02.
    The mail body coming with text " sales order is blocked" sopme thing like this.
    This same mail i have to sent to the mail id maintained in Custom table plant wise.
    Regards
    Ramakrishna L

Maybe you are looking for

  • How can i replace some string  in a JTextaArea/JTex at current time!

    Hey guys, this problem is driving me crazy... i want to do a keyboard event.. like the emoticons in msn, so, i want that when i type /land ("latex comand"), a character appears replacing the command in the JTextArea. I did it, but when i type /happy,

  • Distributed transactions/jdbc problem WL60

    Hi           Our company has aworking application running on WLS5.1sp9.           Im in the process of migrating it to WL6.0sp2.           Our domain has 2 clusters each running 2 servers:           1) servlet engines (handling http requests from cli

  • Setup Assistant Freezes after installation.. cannot complete setup

    Hi - I recently installed an Apple DVD RAM drive in my 450Mhz B&W G3. As far as I know it meets the system requirements - it has 640MB RAM and built in firewire. Anyway, I was upgrading from OS 10.2.8 and I kept getting an error. So I ran the disk ut

  • Error message after downloading OSX Mountain Lion 10.8.2

    I downloaded OSX Mountain Lion last night and now I continue to get a error message that says "There was a problem connecting to the server.  URLs with the type 'file' are not supported." What does this mean?

  • Make an SSL connection to other server from ce WebAS

    Hi all, does anyone know what should I do to make an application that's running on my AS (I have the CE 7.1 SP4 installed) call a web service that is running on a remote server, which can be address only via ssl. I have installed the certificate from