Friday, December 30, 2011

JavaMail

I am using JavaMail to try to send mail.

I am using smtp as the protocol.

I had to add authentication for the connection.

if (mailhost != null)
props.put("mail." + prot + ".host", mailhost);
if (auth) {
props.put("mail.smtp.starttls.enable","true");
props.put("mail." + prot + ".auth", "true");
}

I had to use the keytool program to add a certificate for the server. The easiest way was to open the server authentication in Thunderbird and export the certificate, then use the keytool to import the certificate to the cacerts file.

\Program Files (x86)\Java\jdk1.6.0_20\jre\bin\keytool" -import -file c:\Users\me\server.com.crt -alias myHost -keystore ..\lib\security\cacerts

This worked for one of my mail servers, but did not work for my school server. The error I received was:

ADDRESS FAILED:
com.sun.mail.smtp.SMTPAddressFailedException: 554 : Relay access denied

After reading online, it dawned on me that I cannot use the mail server when I am not on the domain. I connected to the domain with a VPN and the mail was sent.

My third domain still does not authenticate. I have followed the steps for the other two, but I am still receiving the error that a certificate cannot be found. The strange thing is that this is the server for the ISP that I am using to connect to the internet. Maybe I don't need authentication? BINGO!!! It worked without authentication.

Monday, December 26, 2011

Learning Spring

I am using the book Spring in Action, 3rd edition, Walls, to learn about the Spring framework.

I have been following the examples in the book. Everything has worked until the Java configuration at the end of chapter 3. Two jar files are needed to run Spring with Java configuration: asm.jar and cgilib.jar.

Actually, that didn't work. I am using Spring 3.0 and the Java config is now part of the core. The problem is with the cgilib that is used in the library. I added cgilib-nodep.jar at the head of the classpath and it works.

Followers