Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JavaMail on AS400 Authenication Problem

843834May 29 2009 — edited Jun 5 2009
I'm creating a program on the iSeries to send email via a smtp server.

I'm having a problem trying to get Authentication to work. I've already spent a couple days trying everything, and the code works just fine from the PC, but on the iSeries it seems to be ignoring the properites that are set to the session.

Here's the code I'm currently using:

 System.out.println(javax.net.ssl.SSLSocket.class);
        
        System.out.println(System.getProperties());
        System.out.println();
        
    	System.out.println("Obtaining Session");
		Session session = Session.getDefaultInstance(new Properties(),
				new javax.mail.Authenticator() {
					protected PasswordAuthentication getPasswordAuthentication() {
						return new PasswordAuthentication(LOGON, PASSWORD);
					}
				});       
		session.setDebug(true);
		session.setDebugOut(ps);
		System.out.println("Session Obtained: " + session);
		System.out.println();
        
		System.out.println("Adding Properties");
		Properties props = session.getProperties();
		props.put("mail.transport.protocol", "smtp");
		props.put("mail.smtp.host", SMTP_HOST_NAME);
		props.put("mail.smtp.auth", "true");
		props.put("mail.smtp.ehlo", "true");
		props.put("mail.smtp.helo", "false");
		props.put("mail.debug", "true");
		props.put("mail.smtp.starttls.enable", "true");
//		props.put("mail.smtp.ssl.enable", "true");
		System.out.println("Session's Properties: " + session.getProperties().toString());

		System.out.println();
		
		System.out.println("Obtaining Message");
		Message msg = new MimeMessage(session);
		System.out.println("Message Obtained");
		try {
			System.out.println("Adding From");
			InternetAddress addressFrom = new InternetAddress(ADDRESS);
			msg.setFrom(addressFrom);
			
			System.out.println("Adding To");
			InternetAddress addressTo = new InternetAddress("tbudzinski@cybra.com");
			msg.setRecipient(Message.RecipientType.TO, addressTo);
			
			System.out.println("Adding Text");
			msg.setSubject("This is the Subject");
			msg.setContent("This is a test Message", "text/plain");
			
			System.out.println("Obtaining Transport");
			Transport trans = session.getTransport("smtp");
			System.out.println("Transport Obtained: " + trans);

//			Transport.send(msg);
			System.out.println("Connecting Transport");
			trans.connect(SMTP_HOST_NAME, LOGON, PASSWORD);
			System.out.println("Transport Connected: " + trans.isConnected());
			
			System.out.println("Sending Message");
			trans.sendMessage(msg, msg.getAllRecipients());
			System.out.println("Message Sent");
			
			trans.close();
		} catch (Throwable e){
			e.printStackTrace();
		}
And here's the debug out that I'm getting:




class javax.net.ssl.SSLSocket

Obtaining Session
DEBUG: setDebug: JavaMail version 1.4ea
Session Obtained: javax.mail.Session@2f9233fd

Adding Properties
Session's Properties: {mail.smtp.starttls.enable=true, mail.smtp.ehlo=true, mail.debug=true, mail.smtp.helo=false, mail.transport.protocol=smtp, mail.smtp.auth=true, mail.smtp.host=smtp.aol.com}

Obtaining Message
Message Obtained
Adding From
Adding To
Adding Text
Obtaining Transport
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
Transport Obtained: smtp:
Connecting Transport

DEBUG: SMTPTransport trying to connect to host "smtp.aol.com", port 25

DEBUG SMTP RCVD: 220 cia-da05.mx.aol.com ESMTP mail_cia-da05.3; Fri, 29 May 2009 16:01:22 -0400

DEBUG SMTP SENT: helo CYBRA8.CYBRA.COM
DEBUG SMTP RCVD: 250 cia-da05.mx.aol.com OK

DEBUG: SMTPTransport connected to host "smtp.aol.com", port: 25

DEBUG SMTP SENT: NOOP
DEBUG SMTP RCVD: 250 OK

Transport Connected: true
Sending Message
DEBUG SMTP SENT: mail from: <yeahtimmy@aol.com>
DEBUG SMTP RCVD: 556 CLIENT AUTHENTICATION REQUIRED. USE ESMTP EHLO AND AUTH.

javax.mail.MessagingException: 556 CLIENT AUTHENTICATION REQUIRED. USE ESMTP EHLO AND AUTH.

at java.lang.Throwable.<init>(Throwable.java:195)
at java.lang.Exception.<init>(Exception.java:41)
at javax.mail.MessagingException.<init>(MessagingException.java:64)
at com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:510)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:315)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:171)
at com.cybra.email.Emailer.sendMessage(Emailer.java:144)

DEBUG SMTP SENT: quit



I have checked to ensure they are both using Java 1.4, and the jars are exactly the same on the two systems. Any help would be appreciated.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 3 2009
Added on May 29 2009
11 comments
1,099 views