Posted By:
sanjay_pai
Posted On:
Friday, August 10, 2001 02:27 AM
While sending an email thru a java program, it is giving the following error: javax.mail.MessagingException: 553 Authentication required for this domain This program was working till previously but later our company has put some kind of authentication on the outgoing mail server. From then onwards i am facing this problem. can anyone help me??? I'm attaching the code. ------------------------------------ import javax.mail.*; import javax.mail.internet.*; import javax.activation.*; import java.io.*; public class SendMail{ // This constructor composes the message and sends email. public static void main(String[] args){ SendMail sm = new SendMail("
More>>
While sending an email thru a java program, it is giving the following error:
javax.mail.MessagingException: 553 Authentication required for this domain
This program was working till previously but later our company has put some kind of authentication on the outgoing mail server. From then onwards i am facing this problem. can anyone help me??? I'm attaching the code.
------------------------------------
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
import java.io.*;
public class SendMail{
// This constructor composes the message and sends email.
public static void main(String[] args){
SendMail sm = new SendMail("username@yahoo.com","hello",args);
System.out.println("Mail sent");
}
public SendMail(String to, String sub, String[] msgs){
Properties props = new Properties();
props.put("mail.smtp.host","server.cmcltd.com");
Session session = Session.getDefaultInstance(props,null);
try{
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("username@cmcltd.com"));
InternetAddress address = new InternetAddress(to);
msg.setRecipient(Message.RecipientType.TO,address);
msg.setSubject(sub);
msg.setSentDate(new Date());
MimeBodyPart[] mbp = new MimeBodyPart[msgs.length + 3];
for(int j=0; j
mbp[j] = new MimeBodyPart();
int i;
for(i=0; i
mbp[i].setText(msgs[i]);
}
mbp[i++].setText("===================================");
mbp[i++].setText("Thanks & Regards");
mbp[i++].setText("KM Administrator");
Multipart mp = new MimeMultipart();
for(i=0; i
mp.addBodyPart(mbp[i]);
msg.setContent(mp);
Transport.send(msg);
}catch(Exception ex){
System.out.println(ex);
}
}
}
<<Less