MAIL / CATATAN</>↗Mail25 Apr 2012
The following example show you how to send email using Gmail SMTP via TLS connection. The username and password is used to authenticate you against the Gmail. The configuration / properties used for connection to the Gmail SMTP is defined in the createConfiguration() method. The properties include information such as the SMTP host address, port […]
MAIL / CATATAN</>↗Mail25 Apr 2012
In another example you’ve seen how to send email using Gmail SMTP via TLS. See the following example How do I send email using Gmail via TLS?. In this example you will use the SSL connection to connect to Gmail SMTP server. The difference with this is in the properties / configuration that we used […]
MAIL / CATATAN</>↗Mail25 Apr 2012
To ask Java mail to print out a debug message when you run a Java mail program you can add the mail.debug and set the value to true into the properties used to create the session object. The other way is to set the debug setting of the session using the session.setDebug() method and pass […]
MAIL / CATATAN</>↗Mail09 Apr 2012
This code snippet shows you how to validate an email address using the javax.mail.internet.InternetAddress class. The validate() method throws a javax.mail.internet.AddressException when the email address passed to the constructor is not a valid email address. Here is the complete code snippet: package org.kodejava.mail; import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; public class ValidateEmail { public static void main(String[] […]
SPRING CORE / CATATAN</>↗Spring Core09 Apr 2012
When many beans in a context definition will have the same initialization and destroy method name, you can define a default-init-method and default-destroy-method in the attributes of the beans element. This way you don’t have to define individual init-method and destroy-method for each of your beans. When the beans do not supply the method that […]
CORE API / CATATAN</>↗Core API07 Apr 2012
The following example use the java.io.FileInputStream class to read contents of a text file. We’ll read a file located in the temporary directory defined by operating system. This temporary directory can be accessed using the java.io.tmpdir system property. package org.kodejava.io; import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class FileInputStreamDemo { public static void main(String[] args) […]