Aspose.email - sent - hung

Hi,
We developed simple email sent program using ASPOSE.EMAIL API. When tested java program its working fine.

But we are calling this program through IBM BPM. Here its fails after 23-25 minutes as timeout.
When debug and noticed SmtpClient.send(message); this line gets hung.

We are not sure whats the problem, even if there is a problem it should fail after certain time.
In the code we have smtpClient.setConnectionTimeout(3500);
But its not failing after that time and it took more than 23 minutes to throw timeout error in IBM BPM.

SmtpClient client = new SmtpClient(“smtp.gmail.com”, 587, “abc@gmail.com”, “abc@Password”);
client.setSecurityOptions(1);
MailMessage msg = new MailMessage(“abc@gmail.com”, “abcTest@gmail.com”, “Test First Message from Java”, “Body Test from my local system”);
client.setConnectionTimeout(3500);
client.send(msg);

Let me know how to set specified period if client.send not happens want to throw error and capture error.

In earlier java program we use
Properties props = new Properties();
props.put(“mail.smtp.host”, host);
props.put(“mail.smtp.port”, “587”);
props.put(“mail.smtp.auth”, “true”);
props.put(“mail.smtp.starttls.enable”, “true”);
props.put(“mail.smtps.ssl.trust”, host);
javax.mail.Session session = javax.mail.Session.getInstance(props,
new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});

With ASPOSE not sure how to enable SSL and also set starttls properties value.

Thanks
Arul

@Arul99,

You may use the code snippet given below for using SSL. It uses the STARTTLS command to start SSL connection.

client.setSecurityOptions(SecurityOptions.SSLExplicit);

We hope that this answered your question. Please feel free to reach us if additional information is required.

Hi
SecurityOptions.SSLExplicit. is value of 1.

So we can use 1 or SecurityOptions.SSLExplicit.
And also we tried with Auto option as well.

Thanks
Arul

@Arul99,

We were unable to reproduce the issue. We used the code snippet given below for testing. It generated this exception due to timeout.

Exception: Connection failure. Timeout '3500' has been reached.

The email was sent successfully by increasing the timeout.

try {
    SmtpClient smtpClient = new SmtpClient();
    smtpClient.setHost("smtp.gmail.com");
    smtpClient.setUsername("test@gmail.com");
    smtpClient.setPassword("password");
    smtpClient.setPort(587);
    smtpClient.setSecurityOptions(SecurityOptions.SSLExplicit);

    MailMessage mailMessage = new MailMessage("test@gmail.com", "test2@gmail.com", "Test Email Subject", "Test Email Body");

    smtpClient.setConnectionTimeout(3500);
    smtpClient.send(mailMessage);
    smtpClient.dispose();
}
catch (Exception e) {
    System.out.println("Exception: " + e.getMessage());
}

The issue seems to be with IBM BPM. If possible, please provide the execution logs so that we can investigate this further.