Authentication problem

Posted on 2004-11-12
Last Modified: 2012-06-27
      I am sending my mails through smtp.
      If my mail host is
      it works well
      If my mail host
      I get error
      javax.mail.MessagingException: 530 5.7.0 Authentication required

my code is

      String host = "";
      String filename = gDesc.getString("email_attachment");
      String msgText1 = "asdasdasd";
     String subject = "email_subject";
     Properties props = System.getProperties();
                props.put("", host);
     Session session = Session.getDefaultInstance(props, null);
        try {
         MimeMessage msg = new MimeMessage(session);
         msg.setFrom(new InternetAddress(from));
            InternetAddress[] address = InternetAddress.parse(to);
         msg.setRecipients(Message.RecipientType.TO, address);

            MimeBodyPart mbp1 = new MimeBodyPart();
            Multipart mp = new MimeMultipart();
            msg.setSentDate(new Date());
        catch (MessagingException mex)
         Exception ex = null;
         if ((ex = mex.getNextException()) != null)
            {     ex.printStackTrace();         }
I want to work this code smae with host as
Question by:kamran
    LVL 13

    Accepted Solution

    ok some Mail servers are configured to need an account in order to send SMTP, u need to add user and password to ur parameterized input, if an SMTP server dosn't need an account, just check with an (if condition) if the account parameters are not found or equal null

    take a look at this link to see how to use the account (username and password)
    LVL 35

    Assisted Solution

    Try to set this property:

    LVL 13

    Expert Comment

    I think I provided good advice here that may help solve the issue
    LVL 35

    Expert Comment

    I think my comment was the exact solution so I'd say a split 60%-40% between me and petmagdy.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Title # Comments Views Activity
    Connect to IP Camera using Java 4 58
    count7 challenge 12 52
    Books that can get me started on JAVA 2 33
    groovy example issue 10 32
    This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
    Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
    Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
    This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now