title: how to send mail faster using javamail api
body: <p>In my scenario I have generated one pdf using jasper report. I have send a mail to my superior with attach that pdf but the mail sending process take more than a minute. So what I do to send my mail with a second, can you help with any coding formate using javamail api. Here I have given my enter mail sending coding structure for your concern. Thanks</p>
  
  <pre><code>public boolean sendMailForVacation(String subject, String bodyContent,String emailAddress,byte[] pdfFile,String pdfFileName,String company){
            boolean isMailsent=false;
            final String SMTP_HOST= getText("email.smtp.host");
            final String SOCKET_FACTORY_PORT= getText("email.socket.factory.port");
               final String SMTP=getText("email.smtp.port"); 
            final String MAIL_USER_EMAIL_ADDRESS=getText("email.username");
            final String MAIL_USER_PASSWORD= getText("email.password");
            final String EMAIL_FROMNAME= company;//getText("email.fromname");
            try{
             Properties props = new Properties();
             props.put("mail.smtp.host", SMTP_HOST);
             props.put("mail.smtp.socketFactory.port",SOCKET_FACTORY_PORT);
             props.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory");
             props.put("mail.smtp.auth", "true");
             props.put("mail.smtp.port", SMTP);
             Authenticator auth = new SMTPAuthenticator(MAIL_USER_EMAIL_ADDRESS, MAIL_USER_PASSWORD);
                Session session = Session.getInstance(props, auth);
             Message message = new MimeMessage(session);
             InternetAddress from = new InternetAddress(MAIL_USER_EMAIL_ADDRESS,EMAIL_FROMNAME);  
             message.setFrom(from);
             message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(emailAddress));
             message.setSubject(subject);
             MimeMultipart multipart = new MimeMultipart("related");
                    BodyPart messageBodyPart = new MimeBodyPart();
                    messageBodyPart.setContent(bodyContent, "text/html");
                    multipart.addBodyPart(messageBodyPart);
                        messageBodyPart = new MimeBodyPart();
                        ByteArrayDataSource baDS=new ByteArrayDataSource(pdfFile,"application/pdf");//application/vnd.ms-excel  
                        messageBodyPart.setDataHandler(new DataHandler(baDS));  
                        messageBodyPart.setFileName(pdfFileName); 
                        multipart.addBodyPart(messageBodyPart);
                        message.setContent(multipart);
                        Transport.send(message);
                        isMailsent=true;
            }catch(Exception e){
             LOGGER.error(e);
            }
            return isMailsent;
           }
  </code></pre>