Skip to main content


Showing posts from November, 2012

Java Send Mail Using Gmail with Multiple Attachments

Here I am sharing a class for sending mail using Gmail SSL with multiple attachments. Just change the gmailUsername and gmailPass with actual gmail credentials. And also change the to and from address with your desired one.
Here we have used Gmail SSL smtp port for sending mail. You can change it with your own mailing server details.  import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
Author Mridul Chatterjee
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class SendMail {
public static void main(String[] args) {
Properties props = new Properties();
props.put(””, “”);
props.put(”mail.smtp.socketFactory.port”, “465″);