For jboss, use JNDI to look up the "Session", e.g.
Object o = new InitialContext().lookup("java:/Mail");
Session s = (Session)s;
Also, put your server properties in the mail-service.xml file.
but i want to set the serverproperties as servername and the password/username dynamically. If the user is connecting he provides these parameters.