kamran
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.MessagingExcept ion: 530 5.7.0 Authentication required
my code is
String host = "smtp.dia.sbcglobal.net";
String filename = gDesc.getString("email_att achment");
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. RecipientT ype.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
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.MessagingExcept
my code is
String host = "smtp.dia.sbcglobal.net";
String filename = gDesc.getString("email_att
String msgText1 = "asdasdasd";
String subject = "email_subject";
Properties props = System.getProperties();
props.put("mail.smtp.host"
Session session = Session.getDefaultInstance
session.setDebug(debug);
try {
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = InternetAddress.parse(to);
msg.setRecipients(Message.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.