Example usage for org.springframework.messaging MessagingException printStackTrace

List of usage examples for org.springframework.messaging MessagingException printStackTrace

Introduction

In this page you can find the example usage for org.springframework.messaging MessagingException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.rxx.common.util.MailUtil.java

/**
 * html/*from  w  w w. j  ava  2 s .c  o m*/
 *
 * @param host 
 * @param port
 * @param userName
 * @param password
 * @param title
 * @param contenthtml
 * @param toUser
 * @throws javax.mail.MessagingException
 */
public static void sendHtml(String host, int port, String userName, String password, String title,
        String content, String[] toUser) {
    JavaMailSenderImpl senderImpl = new JavaMailSenderImpl();
    // mail server
    senderImpl.setHost(host);
    senderImpl.setPort(port);
    // ,html
    MimeMessage mailMessage = senderImpl.createMimeMessage();

    try {
        MimeMessageHelper messageHelper = new MimeMessageHelper(mailMessage, true, "UTF-8");

        try {
            // 
            messageHelper.setTo(toUser);
            messageHelper.setFrom(userName);
            messageHelper.setSubject(title);
            // true HTML
            messageHelper.setText(content, true);
        } catch (javax.mail.MessagingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        senderImpl.setUsername(userName); // ,username
        senderImpl.setPassword(password); // , password
        Properties prop = new Properties();
        prop.put("mail.smtp.auth", "true"); // true,
        prop.put("mail.smtp.timeout", "25000");
        senderImpl.setJavaMailProperties(prop);
        // 
        senderImpl.send(mailMessage);
    } catch (javax.mail.MessagingException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

}