com.poscoict.glueframework.util.mail
Class GlueSpringMailSender

java.lang.Object
  extended by com.poscoict.glueframework.util.mail.GlueSpringMailSender

public class GlueSpringMailSender
extends Object

GlueSpringMailSender Ŭ·¡½º´Â ½±°Ô SMTP Client¸¦ ±¸ÇöÇÒ ¼ö ÀÖ°Ô ÇÏ´Â ClassÀÌ´Ù. Java Mail ±â¹Ý¿¡¼­ SpringÀÇ JavaMailSender¸¦ ÀÌ¿ëÇÏ¿© ±¸ÇöµÇ¾ú´Ù. Áß°è ¸ÞÀÏ ¼­¹ö·Î´Â SMTP ¼­¹ö¸¦ »ç¿ëÇÑ´Ù. ¸ÞÀÏ ³»¿ëÀº plain text, html ÇüŸ¦ Áö¿øÇϸç euc-kr, utf-8 ÀÎÄÚµùŸÀÔÀ» Áö¿øÇÑ´Ù.

 
 »ç¿ë¿¹)
        JavaMailSender  mailSender = (JavaMailSender) GlueStaticContext.getBeanFactory().getBeanObject( "mailSender" );
        GlueSpringMailSender glueMailSender = null;
        try
        {
            glueMailSender = new GlueSpringMailSender(mailSender);
        } catch ( Exception e1 )
        {
            //¿¡·¯ ó¸®
        }
        String from = "º¸³»´Â »ç¶÷ Mail ÁÖ¼Ò";
        String to = "¹Þ´Â »ç¶÷ Mail ÁÖ¼Ò";
        String subject = "Á¦¸ñ";
        String content = "³»¿ë";
        String[] file = {"E:\\temp\\test.txt","E:\\temp\\test2.txt"};
        try
        {
            glueMailSender.setFrom( from );
            glueMailSender.setTo( to );
            glueMailSender.setText( content );
            glueMailSender.addFiles( file );
            glueMailSender.sendMail();
        } catch ( Exception e )
        {
            //¿¡·¯ ó¸®
        }
 
 


Constructor Summary
GlueSpringMailSender(org.springframework.mail.javamail.JavaMailSender mailSender)
          »ý¼ºÀÚ(constructor).
GlueSpringMailSender(org.springframework.mail.javamail.JavaMailSender mailSender, boolean multipart)
          »ý¼ºÀÚ(constructor).
GlueSpringMailSender(org.springframework.mail.javamail.JavaMailSender mailSender, boolean multipart, String encoding)
          »ý¼ºÀÚ(constructor).
 
Method Summary
 void addFile(String filepath)
          Message¿¡ ÷ºÎÆÄÀÏ ¼³Á¤
 void addFiles(String[] filepath)
          Message¿¡ ÷ºÎÆÄÀÏ ¼³Á¤
 org.springframework.mail.javamail.MimeMessageHelper getMessageHelper()
          Spring¿¡¼­ Á¦°øÇÏ´Â MimeMessageHelper¸¦ ¹ÝȯÇÑ´Ù.
 void sendMail()
          ¼³Á¤µÈ Message¸¦ Mail·Î º¸³½´Ù.
 void sendMail(String from, String[] to, String subject, String content)
          ¼³Á¤µÈ Message¸¦ Mail·Î º¸³½´Ù.
 void sendMail(String from, String[] to, String subject, String content, String filepath)
          ¼³Á¤µÈ Message¸¦ Mail·Î º¸³½´Ù.
 void sendMail(String from, String[] to, String subject, String content, String[] filepath)
          ¼³Á¤µÈ Message¸¦ Mail·Î º¸³½´Ù.
 void sendMail(String from, String to, String subject, String content)
          ¼³Á¤µÈ Message¸¦ Mail·Î º¸³½´Ù.
 void sendMail(String from, String to, String subject, String content, String filepath)
          ¼³Á¤µÈ Message¸¦ Mail·Î º¸³½´Ù.
 void sendMail(String from, String to, String subject, String content, String[] filepath)
          ¼³Á¤µÈ Message¸¦ Mail·Î º¸³½´Ù.
 void sendMailHtml(String from, String[] to, String subject, String content)
          ¼³Á¤µÈ Message¸¦ Mail·Î º¸³½´Ù.
 void sendMailHtml(String from, String[] to, String subject, String content, String filepath)
          ¼³Á¤µÈ Message¸¦ Mail·Î º¸³½´Ù.
 void sendMailHtml(String from, String[] to, String subject, String content, String[] filepath)
          ¼³Á¤µÈ Message¸¦ Mail·Î º¸³½´Ù.
 void sendMailHtml(String from, String to, String subject, String content)
          ¼³Á¤µÈ Message¸¦ Mail·Î º¸³½´Ù.
 void sendMailHtml(String from, String to, String subject, String content, String filepath)
          ¼³Á¤µÈ Message¸¦ Mail·Î º¸³½´Ù.
 void sendMailHtml(String from, String to, String subject, String content, String[] filepath)
          ¼³Á¤µÈ Message¸¦ Mail·Î º¸³½´Ù.
 void setBcc(String bcc)
          Message¿¡ BCC ¼³Á¤
 void setBcc(String[] bcc)
          Message¿¡ BCC ¼³Á¤
 void setCc(String cc)
          Message¿¡ CC ¼³Á¤
 void setCc(String[] cc)
          Message¿¡ CC ¼³Á¤
 void setFrom(String from)
          Message¿¡ º¸³»´Â »ç¶÷ Mail ÁÖ¼Ò ¼³Á¤
 void setSubject(String subject)
          Message¿¡ Á¦¸ñ ¼³Á¤
 void setText(String content)
          Message¿¡ º»¹® ¼³Á¤
 void setTextHtml(String content)
          Message¿¡ º»¹®(HTMLÇü½Ä) ¼³Á¤
 void setTo(String to)
          Message¿¡ ¹Þ´Â »ç¶÷ Mail ÁÖ¼Ò ¼³Á¤
 void setTo(String[] to)
          Message¿¡ ¹Þ´Â »ç¶÷ Mail ÁÖ¼Ò ¼³Á¤
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GlueSpringMailSender

public GlueSpringMailSender(org.springframework.mail.javamail.JavaMailSender mailSender)
                     throws MessagingException
»ý¼ºÀÚ(constructor).

Parameters:
mailSender - GlueSpringMailSender¸¦ »ç¿ëÇϱâ À§Çؼ­´Â SpringÀÇ JavaMailSender°¡ ²À ÇÊ¿äÇÏ´Ù.
Throws:
MessagingException

GlueSpringMailSender

public GlueSpringMailSender(org.springframework.mail.javamail.JavaMailSender mailSender,
                            boolean multipart)
                     throws MessagingException
»ý¼ºÀÚ(constructor).

Parameters:
mailSender - GlueSpringMailSender¸¦ »ç¿ëÇϱâ À§Çؼ­´Â SpringÀÇ JavaMailSender°¡ ²À ÇÊ¿äÇÏ´Ù.
multipart - multipart ¿©ºÎ ÆÄÀÏ Ã·ºÎÇÒ °æ¿ì¿¡´Â ¹Ýµå½Ã true·Î ¼³Á¤(Default:true)
Throws:
MessagingException

GlueSpringMailSender

public GlueSpringMailSender(org.springframework.mail.javamail.JavaMailSender mailSender,
                            boolean multipart,
                            String encoding)
                     throws MessagingException
»ý¼ºÀÚ(constructor).

Parameters:
mailSender - GlueSpringMailSender¸¦ »ç¿ëÇϱâ À§Çؼ­´Â SpringÀÇ JavaMailSender°¡ ²À ÇÊ¿äÇÏ´Ù.
multipart - multipart ¿©ºÎ ÆÄÀÏ Ã·ºÎÇÒ °æ¿ì¿¡´Â ¹Ýµå½Ã true·Î ¼³Á¤(Default:true)
encoding - encoding ¼³Á¤(Default:UTF-8)
Throws:
MessagingException
Method Detail

getMessageHelper

public org.springframework.mail.javamail.MimeMessageHelper getMessageHelper()
Spring¿¡¼­ Á¦°øÇÏ´Â MimeMessageHelper¸¦ ¹ÝȯÇÑ´Ù.

Returns:

sendMail

public void sendMail()
¼³Á¤µÈ Message¸¦ Mail·Î º¸³½´Ù.


sendMail

public void sendMail(String from,
                     String to,
                     String subject,
                     String content)
              throws Exception
¼³Á¤µÈ Message¸¦ Mail·Î º¸³½´Ù.

Parameters:
from - º¸³»´Â »ç¶÷ Mail ÁÖ¼Ò
to - ¹Þ´Â »ç¶÷ Mail ÁÖ¼Ò
subject - Á¦¸ñ
content - º»¹®
Throws:
Exception

sendMail

public void sendMail(String from,
                     String[] to,
                     String subject,
                     String content)
              throws Exception
¼³Á¤µÈ Message¸¦ Mail·Î º¸³½´Ù.

Parameters:
from - º¸³»´Â »ç¶÷ Mail ÁÖ¼Ò
to - ¹Þ´Â »ç¶÷ Mail ÁÖ¼Ò
subject - Á¦¸ñ
content - º»¹®
Throws:
Exception

sendMail

public void sendMail(String from,
                     String to,
                     String subject,
                     String content,
                     String filepath)
              throws Exception
¼³Á¤µÈ Message¸¦ Mail·Î º¸³½´Ù.

Parameters:
from - º¸³»´Â »ç¶÷ Mail ÁÖ¼Ò
to - ¹Þ´Â »ç¶÷ Mail ÁÖ¼Ò
subject - Á¦¸ñ
content - º»¹®
filepath - ÷ºÎÆÄÀÏ Path
Throws:
Exception

sendMail

public void sendMail(String from,
                     String[] to,
                     String subject,
                     String content,
                     String filepath)
              throws Exception
¼³Á¤µÈ Message¸¦ Mail·Î º¸³½´Ù.

Parameters:
from - º¸³»´Â »ç¶÷ Mail ÁÖ¼Ò
to - ¹Þ´Â »ç¶÷ Mail ÁÖ¼Ò
subject - Á¦¸ñ
content - º»¹®
filepath - ÷ºÎÆÄÀÏ Path
Throws:
Exception

sendMail

public void sendMail(String from,
                     String to,
                     String subject,
                     String content,
                     String[] filepath)
              throws Exception
¼³Á¤µÈ Message¸¦ Mail·Î º¸³½´Ù.

Parameters:
from - º¸³»´Â »ç¶÷ Mail ÁÖ¼Ò
to - ¹Þ´Â »ç¶÷ Mail ÁÖ¼Ò
subject - Á¦¸ñ
content - º»¹®
filepath - ÷ºÎÆÄÀÏ Path
Throws:
Exception

sendMail

public void sendMail(String from,
                     String[] to,
                     String subject,
                     String content,
                     String[] filepath)
              throws Exception
¼³Á¤µÈ Message¸¦ Mail·Î º¸³½´Ù.

Parameters:
from - º¸³»´Â »ç¶÷ Mail ÁÖ¼Ò
to - ¹Þ´Â »ç¶÷ Mail ÁÖ¼Ò
subject - Á¦¸ñ
content - º»¹®
filepath - ÷ºÎÆÄÀÏ Path
Throws:
Exception

sendMailHtml

public void sendMailHtml(String from,
                         String to,
                         String subject,
                         String content)
                  throws Exception
¼³Á¤µÈ Message¸¦ Mail·Î º¸³½´Ù.

Parameters:
from - º¸³»´Â »ç¶÷ Mail ÁÖ¼Ò
to - ¹Þ´Â »ç¶÷ Mail ÁÖ¼Ò
subject - Á¦¸ñ
content - º»¹®(HtmlÇü½Ä)
Throws:
Exception

sendMailHtml

public void sendMailHtml(String from,
                         String[] to,
                         String subject,
                         String content)
                  throws Exception
¼³Á¤µÈ Message¸¦ Mail·Î º¸³½´Ù.

Parameters:
from - º¸³»´Â »ç¶÷ Mail ÁÖ¼Ò
to - ¹Þ´Â »ç¶÷ Mail ÁÖ¼Ò
subject - Á¦¸ñ
content - º»¹®(HtmlÇü½Ä)
Throws:
Exception

sendMailHtml

public void sendMailHtml(String from,
                         String to,
                         String subject,
                         String content,
                         String filepath)
                  throws Exception
¼³Á¤µÈ Message¸¦ Mail·Î º¸³½´Ù.

Parameters:
from - º¸³»´Â »ç¶÷ Mail ÁÖ¼Ò
to - ¹Þ´Â »ç¶÷ Mail ÁÖ¼Ò
subject - Á¦¸ñ
content - º»¹®(HtmlÇü½Ä)
filepath - ÷ºÎÆÄÀÏ Path
Throws:
Exception

sendMailHtml

public void sendMailHtml(String from,
                         String[] to,
                         String subject,
                         String content,
                         String filepath)
                  throws Exception
¼³Á¤µÈ Message¸¦ Mail·Î º¸³½´Ù.

Parameters:
from - º¸³»´Â »ç¶÷ Mail ÁÖ¼Ò
to - ¹Þ´Â »ç¶÷ Mail ÁÖ¼Ò
subject - Á¦¸ñ
content - º»¹®(HtmlÇü½Ä)
filepath - ÷ºÎÆÄÀÏ Path
Throws:
Exception

sendMailHtml

public void sendMailHtml(String from,
                         String to,
                         String subject,
                         String content,
                         String[] filepath)
                  throws Exception
¼³Á¤µÈ Message¸¦ Mail·Î º¸³½´Ù.

Parameters:
from - º¸³»´Â »ç¶÷ Mail ÁÖ¼Ò
to - ¹Þ´Â »ç¶÷ Mail ÁÖ¼Ò
subject - Á¦¸ñ
content - º»¹®(HtmlÇü½Ä)
filepath - ÷ºÎÆÄÀÏ Path
Throws:
Exception

sendMailHtml

public void sendMailHtml(String from,
                         String[] to,
                         String subject,
                         String content,
                         String[] filepath)
                  throws Exception
¼³Á¤µÈ Message¸¦ Mail·Î º¸³½´Ù.

Parameters:
from - º¸³»´Â »ç¶÷ Mail ÁÖ¼Ò
to - ¹Þ´Â »ç¶÷ Mail ÁÖ¼Ò
subject - Á¦¸ñ
content - º»¹®(HtmlÇü½Ä)
filepath - ÷ºÎÆÄÀÏ Path
Throws:
Exception

setFrom

public void setFrom(String from)
             throws MessagingException
Message¿¡ º¸³»´Â »ç¶÷ Mail ÁÖ¼Ò ¼³Á¤

Throws:
MessagingException

setTo

public void setTo(String to)
           throws MessagingException
Message¿¡ ¹Þ´Â »ç¶÷ Mail ÁÖ¼Ò ¼³Á¤

Throws:
MessagingException

setTo

public void setTo(String[] to)
           throws MessagingException
Message¿¡ ¹Þ´Â »ç¶÷ Mail ÁÖ¼Ò ¼³Á¤

Throws:
MessagingException

setSubject

public void setSubject(String subject)
                throws MessagingException
Message¿¡ Á¦¸ñ ¼³Á¤

Throws:
MessagingException

setText

public void setText(String content)
             throws MessagingException
Message¿¡ º»¹® ¼³Á¤

Throws:
MessagingException

setTextHtml

public void setTextHtml(String content)
                 throws MessagingException
Message¿¡ º»¹®(HTMLÇü½Ä) ¼³Á¤

Throws:
MessagingException

setCc

public void setCc(String cc)
           throws MessagingException
Message¿¡ CC ¼³Á¤

Throws:
MessagingException

setCc

public void setCc(String[] cc)
           throws MessagingException
Message¿¡ CC ¼³Á¤

Throws:
MessagingException

setBcc

public void setBcc(String bcc)
            throws MessagingException
Message¿¡ BCC ¼³Á¤

Throws:
MessagingException

setBcc

public void setBcc(String[] bcc)
            throws MessagingException
Message¿¡ BCC ¼³Á¤

Throws:
MessagingException

addFile

public void addFile(String filepath)
             throws MessagingException
Message¿¡ ÷ºÎÆÄÀÏ ¼³Á¤

Throws:
MessagingException

addFiles

public void addFiles(String[] filepath)
              throws MessagingException
Message¿¡ ÷ºÎÆÄÀÏ ¼³Á¤

Throws:
MessagingException


Copyright © 2013–2014 POSCO ICT SWÁ¦Ç°±â¼úÆÀ. All rights reserved.