title: Java Mail timeout & connectiontimeout handling
body: <p>I'm using JavaMail to send email requests to an SMTP server.</p>
  
  <p>I would like to set both <strong>"mail.smtp.connectiontimeout"</strong> and <strong>"mail.smtp.timeout"</strong> properties within my code.</p>
  
  <p>Programmatically, I want to catch both when <em>timeout</em> and/or <em>connectiontimeout</em> operations are reached in Java and handle things accordingly. Handling in the sense, I need to retry the same email once again the next time.</p>
  
  <p>How do I handle this in Java/JavaMail?  Is it possible to catch &amp; handle this timeout operations?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Also, is it possible to simulate/reproduce this timeout operation on my own assuming I've complete administration access to the SMTP server?</p>