Authentication problem

      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
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Try to set this property:

I think I provided good advice here that may help solve the issue
I think my comment was the exact solution so I'd say a split 60%-40% between me and petmagdy.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.