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!

Authentication with CRAM-MD5 not work :(

843834Oct 9 2007 — edited Oct 11 2007
I not seem to be able to connect and send an email through a smtp server that uses CRAM-MD5 for authentication.
I keep on getting the error:
---
com.sun.mail.smtp.SMTPSendFailedException: 530 authentication required for mail submission
----

Please some tips/help on how to solve this ?
Below you find the debug output.

I also tried it with other peaces snippes ot code that I found on the internet, but it keeps on giving me the same error.
The piece of code I use:
		Properties properties = System.getProperties();
		properties.put("mail.smtp.host", server);
		properties.put("mail.smtp.auth", "true");
		Session ses = Session.getInstance(properties);
		ses.setDebug(true);

		MimeMessage msg = new MimeMessage(ses);

		msg.setFrom(new InternetAddress(fromAddress));

		msg.addRecipients(Message.RecipientType.TO, toAddress);
		msg.setContent(body, "text/plain");

		msg.setSubject(subject);
		msg.saveChanges();

		Transport tr = ses.getTransport("smtp");
// I am not sure about the one below, but it has no effect on the error
		((SMTPTransport) tr).setSASLRealm("CRAM-MD5");
		
		tr.connect(server, userName, password);
		tr.sendMessage(msg, msg.getAllRecipients());
		tr.close();
The debug output:
DEBUG: JavaMail version 1.4ea
DEBUG: java.io.FileNotFoundException: C:\Program Files\Java\jdk1.6.0_03\jre\lib\javamail.providers (The system cannot find the file specified)
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.providers
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]}
DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]}
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.address.map
DEBUG: java.io.FileNotFoundException: C:\Program Files\Java\jdk1.6.0_03\jre\lib\javamail.address.map (The system cannot find the file specified)
DEBUG: setDebug: JavaMail version 1.4ea
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "HOST", port 25, isSSL false
220 ontrob1.bmsg.nl ESMTP Service (7.0.043) ready
DEBUG SMTP: connected to host "HOST", port: 25

EHLO laptop-ed
250-ontrob1.bmsg.nl
250-DSN
250-8BITMIME
250-HELP
250-AUTH CRAM-MD5
250-STARTTLS
250 SIZE 2097152
DEBUG SMTP: Found extension "DSN", arg ""
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "HELP", arg ""
DEBUG SMTP: Found extension "AUTH", arg "CRAM-MD5"
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "SIZE", arg "2097152"
DEBUG SMTP: Attempt to authenticate
DEBUG SMTP: use8bit false
MAIL FROM:<CFT00290@cft.obebd.nl>
530 authentication required for mail submission
com.sun.mail.smtp.SMTPSendFailedException: 530 authentication required for mail submission

	at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1388)
	at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:959)
	at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:583)
	at com.bv.taxes.Mailer.sendMail(Mailer.java:64)
	at com.bv.taxes.IbSenderTest.bla(IbSenderTest.java:90)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580)
	at org.testng.internal.Invoker.invokeMethod(Invoker.java:473)
	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:567)
	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:834)
	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
	at org.testng.TestRunner.runWorkers(TestRunner.java:689)
	at org.testng.TestRunner.privateRun(TestRunner.java:566)
	at org.testng.TestRunner.run(TestRunner.java:466)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:301)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:296)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:276)
	at org.testng.SuiteRunner.run(SuiteRunner.java:191)
	at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:808)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:776)
	at org.testng.TestNG.run(TestNG.java:701)
	at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73)
	at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:124)
FAILED: bla
com.sun.mail.smtp.SMTPSendFailedException: 530 authentication required for mail submission

	at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1388)
	at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:959)
	at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:583)
	at com.bv.taxes.Mailer.sendMail(Mailer.java:64)
	at com.bv.taxes.IbSenderTest.bla(IbSenderTest.java:90)
... Removed 22 stack frames
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 8 2007
Added on Oct 9 2007
6 comments
1,415 views