Validate email address with Java Mail API

In this example we are going to see how to validate email addresses using Java Mail API. The mail API provides the programmer an easy to use suite in order to handle mail management inside his application. You can use this example when you want to perform input validation on your parameters before using them. In order to validate email ...

Read More »

Send email with attachment

With this tutorial we are going to see how to send an email with an attachment in a Java Application. This is particularly useful when you want to handle email activities inside your application. Basically, all you have to do to send email with attachment is: Set SMTP properties using a Properties object. Use properties.put("", "") to set the smtp ...

Read More »

Send file via mail using FileDataSource example

With this example we are going to see how to sent a file using FileDataSource. In this example we are using Gmail as our smtp server. This requires that you have a Google account. You may use any smtp server you want by changing the host properties. In short, in order to send file via email you have to: Set ...

Read More »

Send e-mail via GMail

With this example we are going to see how to send an e-mail via GMail in a Java program. To do that you have to specify certain parameters about the SMTP host you have to use. In short to send an email via GMail in a Java Application, one should follow these steps: Set smtp properties using a Properties object. ...

Read More »

Sending emails with JavaMail

Sending a simple text message // Common variables String host = "your_smtp_server"; String from = "from_address"; String to = "to_address"; // Set properties Properties props = new Properties(); props.put("", host); props.put("mail.debug", "true"); // Get session Session session = Session.getInstance(props); try { // Instantiate a message Message msg = new MimeMessage(session); // Set the FROM message msg.setFrom(new InternetAddress(from)); // The recipients ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns