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(JavaMailSender mailSender)
          생성자(constructor).
GlueSpringMailSender(JavaMailSender mailSender, boolean multipart)
          생성자(constructor).
GlueSpringMailSender(JavaMailSender mailSender, boolean multipart, String encoding)
          생성자(constructor).
 
Method Summary
 void addFile(String filepath)
          Message에 첨부파일 설정
 void addFiles(String[] filepath)
          Message에 첨부파일 설정
 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(JavaMailSender mailSender)
                     throws MessagingException
생성자(constructor).

Parameters:
mailSender - GlueSpringMailSender를 사용하기 위해서는 Spring의 JavaMailSender가 꼭 필요하다.
Throws:
MessagingException

GlueSpringMailSender

public GlueSpringMailSender(JavaMailSender mailSender,
                            boolean multipart)
                     throws MessagingException
생성자(constructor).

Parameters:
mailSender - GlueSpringMailSender를 사용하기 위해서는 Spring의 JavaMailSender가 꼭 필요하다.
multipart - multipart 여부 파일 첨부할 경우에는 반드시 true로 설정(Default:true)
Throws:
MessagingException

GlueSpringMailSender

public GlueSpringMailSender(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 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–2016 POSCO ICT. All rights reserved.