javamail - create user accounts in apache james with java api -



javamail - create user accounts in apache james with java api -

i need add together new users in apache james mail service server using java api, in whole net there not illustration of how utilize it. http://james.apache.org/server/2.3.1/adding_users.html java mail service api can send mail service apache james mailbox read messages, that.

string user = "user"; // newly created user on james string password = "user"; // user password string fromaddress = "user@localhost"; // newlycreateduser@localhost string toaddress = "usver@gmail.com"; // create mail service session properties properties = new properties(); properties.put("mail.smtp.host", "localhost"); properties.put("mail.smtp.port", "25"); properties.put("mail.smtp.username", user); properties.put("mail.smtp.password", password); session session = session.getdefaultinstance(properties, null); seek { message message = new mimemessage(session); message.setfrom(new internetaddress(fromaddress)); message.setrecipients(message.recipienttype.to, internetaddress.parse(toaddress)); message.setsubject("email our james server"); message.settext("hello world 1 time again , again"); transport.send(message); system.out.println("email sent successfully"); } grab (messagingexception e) { e.printstacktrace(); }

anybody know or used james java api? examples?

here equivalent java code:

public static void main(string [] args){ adduser(args[0]); } static void adduser(string email){ try{ string serverurl = "service:jmx:rmi:///jndi/rmi://localhost:9999/jmxrmi"; string beannameuser = "org.apache.james:type=component,name=usersrepository"; string beannamedomain = "org.apache.james:type=component,name=domainlist"; mbeanserverconnection server = jmxconnectorfactory.connect(new jmxserviceurl(serverurl)).getmbeanserverconnection(); usersrepositorymanagementmbean userbean = mbeanserverinvocationhandler.newproxyinstance(server, new objectname(beannameuser), usersrepositorymanagementmbean.class, false); domainlistmanagementmbean domainbean = mbeanserverinvocationhandler.newproxyinstance(server, new objectname(beannamedomain), domainlistmanagementmbean.class, false); if(domainbean.containsdomain(email.split("@")[1]) && !userbean.verifyexists(email)){ system.out.println("creating email : "+email ); userbean.adduser(email,"password"); }else{ system.out.println("domain not exist or user exists !!"); } }catch (exception e){ system.out.println("something went wrong"); } }

java javamail james

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -