Hi Everybody.
I am new to Java, but have been a while with computers from the good old days with Fortran!. I am creating an application and needed to send e-mails with passwords/other information to people and learn that I can do it with Javamail. I read, copied and eventually something working fine about 2 years ago. I needed to resurrect the program again and now it does not work. The server has changed names and requires authentication. Using the same methodology as before, went to forums, copied materials but I have failed and do not know how to solve the problem.

the code that I am using is:

//package programA;
import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;
import javax.mail.AuthenticationFailedException;

* modified program based on sendfile by Java Sun Microsystems -
* @author Christopher Cotton
public class se3 {

public static void main(String[] args) {

class MailAuthenticator extends Authenticator {

public MailAuthenticator() {

public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("username", "password");

// create some properties and get the default Session
Properties props = System.getProperties();
props.put("mail.smtp.host", host);
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "110");
props.put("mail.smtp.starttls.enable", "true");

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) {

The results that I am getting are:
Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-2001.



C:\4CP>java -cp c:\4cp;c:\4cp\activation.jar;c:\4cp\mail.jar se3 me me solerapc.
com c:\4cp\p1.html P P true E E

DEBUG: setDebug: JavaMail version 1.4.1
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.s
mtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
at javax.mail.Service.connect(Service.java:319)
at javax.mail.Service.connect(Service.java:169)
at javax.mail.Service.connect(Service.java:118)
at javax.mail.Transport.send0(Transport.java:188)
at javax.mail.Transport.send(Transport.java:118)
at se3.main(se3.java:203)

I pass the parameters and they are println OK - I have tried everything that I can think about without success. I have spend days reading forums, trying other port numbers as per my outlook, used three e-mail accounts, smtp, pop3, etc, without effect.

I am using jdk 6.07, mail 1.4.1. I have telnetted the server OK.

Your kindness in helping a frustrated fellow. Since I am new to java, it seems like I am putting together a very complicated puzzle without the picture and the debug outputs tell me nothing.

thank you.