As both Alejandro and HuiSheng mentioned you shall use javax.mail.Authenticator to achieve what you described.
I have made few tests with that and it seems to work properly but it is not documented officially anywhere.
Following is brief description of steps needed to configure and use it:
1. Create custom implementation of Authenticator interface:
import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;
public class MyAuthenticator extends Authenticator {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("your user name", "your password");
}
}
2. Configure jbpm to use your custom Authenticator, extend default jbpm configuration:
<mail-session>
<mail-server>
<session-properties resource="jbpm.mail.properties" />
<authenticator class="MyAuthenticator" auto-wire="true"/>
</mail-server>
</mail-session>
3. mail settings (jbpm.mail.properties):
mail.smtp.auth=true
mail.smtp.host=smtp.gmail.com
mail.smtp.port=465
mail.smtp.socketFactory.port=465
mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
After these steps I was able to send emails from my gmail account to any email address.
HTH
Maciej