Link to home
Start Free TrialLog in
Avatar of kamran
kamranFlag for Pakistan

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of petmagdy
petmagdy
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of girionis
girionis
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.