class DefaultMailErrorHandler implements MailErrorHandler {

	private static final int DEFAULT_MAX_MESSAGE_LENGTH = 1024;

	private int maxMessageLength = DEFAULT_MAX_MESSAGE_LENGTH;

	/**
	 * The limit for the size of message that will be copied to the exception message.
	 * Output will be truncated beyond that. Default value is 1024.
	 * @param maxMessageLength the maximum message length
	 */
	public void setMaxMessageLength(int maxMessageLength) {
		this.maxMessageLength = maxMessageLength;
	}

	/**
	 * Wraps the input exception with a runtime {@link MailException}. The exception
	 * message will contain the failed message (using toString).
	 * @param message a failed message
	 * @param exception a MessagingException
	 * @throws MailException a translation of the Exception
	 * @see MailErrorHandler#handle(MailMessage, Exception)
	 */
	@Override
	public void handle(MailMessage message, Exception exception) throws MailException {<FILL_FUNCTION_BODY>}

}

		String msg = message.toString();
		throw new MailSendException(
				"Mail server send failed: " + msg.substring(0, Math.min(maxMessageLength, msg.length())), exception);
	
<no_super_class>