Authentication problem

Hello,
      I am sending my mails through smtp.
      If my mail host is mail.multi.net.pk
      it works well
      If my mail host smtp.dia.sbcglobal.net
      I get error
      javax.mail.MessagingException: 530 5.7.0 Authentication required

my code is

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

            MimeBodyPart mbp1 = new MimeBodyPart();
            mbp1.setText(msgText1);
            Multipart mp = new MimeMultipart();
            mp.addBodyPart(mbp1);
            msg.setContent(mp);
            msg.setSentDate(new Date());
          Transport.send(msg);
        }
        catch (MessagingException mex)
        {
         mex.printStackTrace();
         Exception ex = null;
         if ((ex = mex.getNextException()) != null)
            {     ex.printStackTrace();         }
       }
I want to work this code smae with host as smtp.dia.sbcglobal.net
kamranAsked:
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.

petmagdyCommented:
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)

http://www.websina.com/bugzero/kb/sunmail-properties.html
0

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
girionisCommented:
Try to set this property:

props.put("mail.smtp.auth","true");
0
petmagdyCommented:
I think I provided good advice here that may help solve the issue
0
girionisCommented:
I think my comment was the exact solution so I'd say a split 60%-40% between me and petmagdy.
0
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
Java

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.