• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 376
  • Last Modified:

client not authenticated

I get "Client not authenticated" after i run the java code.
the host supports only ntlm authentication - how can i incorporate it in this code
i use java mail.
import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;

public class sendfile {

    public static void main(String[] args) {
//	if (args.length != 5) {
//	    System.out.println("usage: java sendfile <to> <from> <smtp> <file> true|false");
//	    System.exit(1);
//	}

	String to = "jean@lb.com";
	String from = "jean@lb.com";
	String host = "lb.com";
	String filename = "d:\\SSLNOTES.txt";
	//boolean debug = Boolean.valueOf(args[4]).booleanValue();
	boolean debug = true;
	String msgText1 = "Sending a file.\n";
	String subject = "Sending a file";
	
	// create some properties and get the default Session
	Properties props = System.getProperties();
	props.put("mail.smtp.host", host);
	
	Session session = Session.getInstance(props, null);
	session.setDebug(debug);
	
	try {
	    // create a message
	    MimeMessage msg = new MimeMessage(session);
	    msg.setFrom(new InternetAddress(from));
	    InternetAddress[] address = {new InternetAddress(to)};
	    msg.setRecipients(Message.RecipientType.TO, address);
	    msg.setSubject(subject);

	    // create and fill the first message part
	    MimeBodyPart mbp1 = new MimeBodyPart();
	    mbp1.setText(msgText1);

	    // create the second message part
	    MimeBodyPart mbp2 = new MimeBodyPart();

	    // attach the file to the message
	    mbp2.attachFile(filename);

	    /*
	     * Use the following approach instead of the above line if
	     * you want to control the MIME type of the attached file.
	     * Normally you should never need to do this.
	     *
	    FileDataSource fds = new FileDataSource(filename) {
		public String getContentType() {
		    return "application/octet-stream";
		}
	    };
	    mbp2.setDataHandler(new DataHandler(fds));
	    mbp2.setFileName(fds.getName());
	     */

	    // create the Multipart and add its parts to it
	    Multipart mp = new MimeMultipart();
	    mp.addBodyPart(mbp1);
	    mp.addBodyPart(mbp2);

	    // add the Multipart to the message
	    msg.setContent(mp);

	    // set the Date: header
	    msg.setSentDate(new Date());

	    /*
	     * If you want to control the Content-Transfer-Encoding
	     * of the attached file, do the following.  Normally you
	     * should never need to do this.
	     *
	    msg.saveChanges();
	    mbp2.setHeader("Content-Transfer-Encoding", "base64");
	     */

	    // send the message
	    Transport.send(msg);
	    
	} catch (MessagingException mex) {
	    mex.printStackTrace();
	    Exception ex = null;
	    if ((ex = mex.getNextException()) != null) {
		ex.printStackTrace();
	    }
	} catch (IOException ioex) {
	    ioex.printStackTrace();
	}
    }
}

Open in new window

0
joseph301074
Asked:
joseph301074
  • 2
1 Solution
 
OsmozeCommented:
i m not expert in Javamail , but i know that if you send an email to a email server where anonymous user are not allowed , you ll recive Mailerdeamon response with the error client not authenticated .
(in exchange server activate anonymous on the recieve connector )
0
 
Sudeep SharmaTechnical DesignerCommented:
0
 
Sudeep SharmaTechnical DesignerCommented:
0
 
joseph301074Author Commented:
partially useful
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now