class EmailUtil {

	public static boolean send(String receiverName, String receiverAccount, String subject, String content) {
		Properties props = System.getProperties();
		props.setProperty("mail.transport.protocol", "smtp");
		props.setProperty("mail.smtp.host", SENDER_SMTP_HOST);
		props.setProperty("mail.smtp.auth", "true");

		Session session = Session.getDefaultInstance(props);
		// 设置为debug模式, 可以查看详细的发送log
		session.setDebug(DEBUG);

		Transport transport = null;
		try {
			MimeMessage message = createMimeMessage(session, receiverName, receiverAccount, subject, content);
			transport = session.getTransport();
			transport.connect(SENDER_ACCOUNT, SENDER_PASSWORD);
			transport.sendMessage(message, message.getAllRecipients());
		} catch (UnsupportedEncodingException | MessagingException e) {
			logger.error(EMAIL_SEND_ERROR, e);
			return false;
		} finally {
			try {
				if (transport != null) {
					transport.close();
				}
			} catch (MessagingException e) {
				logger.error(EMAIL_SEND_ERROR, e);
			}
		}
		return true;
	}

}