client  not authenticated

Posted on 2011-05-02
Last Modified: 2012-05-11
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 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 = "";
	String from = "";
	String host = "";
	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("", host);
	Session session = Session.getInstance(props, null);
	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);

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

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

	    // attach the file to the message

	     * 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));

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

	    // add the Multipart to the message

	    // 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.
	    mbp2.setHeader("Content-Transfer-Encoding", "base64");

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

Open in new window

Question by:joseph301074
    LVL 6

    Expert Comment

    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 )
    LVL 29

    Accepted Solution

    LVL 29

    Expert Comment

    by:Sudeep Sharma

    Author Closing Comment

    partially useful

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
    In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
    Viewers will learn how to properly install and use Secure Shell (SSH) to work on projects or homework remotely. Download Secure Shell: Follow basic installation instructions: Open Secure Shell and use "Quick Connect" to enter credentials includi…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now