protected void sendMail ( FaxJob faxJob , Connection < MailResourcesHolder > mailConnection , Message message ) { if ( message == null ) { this . throwUnsupportedException ( ) ; } else { //get holder MailResourcesHolder mailResourcesHolder = mailConnection . getResource ( ) ; //get transport Transport transport = mailResourcesHolder . getTransport ( ) ; try { //send message message . saveChanges ( ) ; if ( transport == null ) { Transport . send ( message , message . getAllRecipients ( ) ) ; } else { transport . sendMessage ( message , message . getAllRecipients ( ) ) ; } } catch ( Throwable throwable ) { throw new FaxException ( "Unable to send message." , throwable ) ; } finally { if ( ! this . usePersistentConnection ) { try { //close connection this . closeMailConnection ( mailConnection ) ; } catch ( Exception exception ) { //log error Logger logger = this . getLogger ( ) ; logger . logInfo ( new Object [ ] { "Error while releasing mail connection." } , exception ) ; } } } } }
This function will send the mail message .