i going through link , tried execute code.
summary of same follows:
private static final string ssl_factory = "sendmaildemosslsocketfactory"; //sendmaildemosslsocketfactory extends sslsocketfactory properties props = new properties(); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.submitter", emailusername); props.put("mail.smtp.user", emailusername); props.put("mail.smtp.host", smtphostname); props.put("mail.debug", debug); props.put("mail.smtp.port", smtpport); props.put("mail.smtp.ssl.socketfactory.port", smtpport); props.put("mail.smtp.ssl.socketfactory.class", ssl_factory); props.put("mail.smtp.socketfactory.fallback", "true"); props.put("mail.smtp.ssl.enable", "true"); props.put("mail.smtp.starttls.enable", "true"); props.setproperty("mail.smtps.ssl.enable", "true"); props.put("mail.transport.protocol", "smtps"); props.put("mail.smtp.ssl.trust", smtphostname); session session = session.getdefaultinstance(props, new javax.mail.authenticator() { protected passwordauthentication getpasswordauthentication() { return new passwordauthentication(emailusername, emailpassword); } }); session.setdebug(boolean.parseboolean(debug)); message msg = new mimemessage(session); //set message smtpssltransport transport = (smtpssltransport) session .gettransport("smtps"); transport.connect(smtphostname, new integer(smtpport).intvalue(), emailusername, emailpassword); msg.savechanges(); transport.sendmessage(msg, msg.getallrecipients()); with same able estb successful connection authentication unsuccessful. not able find code going wrong.
debug: javamail version 1.4ea debug: java.io.filenotfoundexception: c:\program files\java\jdk1.7.0_25\jre\lib\javamail.providers (the system cannot find file specified) debug: !anyloaded debug: not loading resource: /meta-inf/javamail.providers debug: loaded resource: /meta-inf/javamail.default.providers debug: tables of loaded providers debug: providers listed class name: {com.sun.mail.smtp.smtpssltransport=javax.mail.provider[transport,smtps,com.sun.mail.smtp.smtpssltransport,sun microsystems, inc], com.sun.mail.smtp.smtptransport=javax.mail.provider[transport,smtp,com.sun.mail.smtp.smtptransport,sun microsystems, inc], com.sun.mail.imap.imapsslstore=javax.mail.provider[store,imaps,com.sun.mail.imap.imapsslstore,sun microsystems, inc], com.sun.mail.pop3.pop3sslstore=javax.mail.provider[store,pop3s,com.sun.mail.pop3.pop3sslstore,sun microsystems, inc], com.sun.mail.imap.imapstore=javax.mail.provider[store,imap,com.sun.mail.imap.imapstore,sun microsystems, inc], com.sun.mail.pop3.pop3store=javax.mail.provider[store,pop3,com.sun.mail.pop3.pop3store,sun microsystems, inc]} debug: providers listed protocol: {imaps=javax.mail.provider[store,imaps,com.sun.mail.imap.imapsslstore,sun microsystems, inc], imap=javax.mail.provider[store,imap,com.sun.mail.imap.imapstore,sun microsystems, inc], smtps=javax.mail.provider[transport,smtps,com.sun.mail.smtp.smtpssltransport,sun microsystems, inc], pop3=javax.mail.provider[store,pop3,com.sun.mail.pop3.pop3store,sun microsystems, inc], pop3s=javax.mail.provider[store,pop3s,com.sun.mail.pop3.pop3sslstore,sun microsystems, inc], smtp=javax.mail.provider[transport,smtp,com.sun.mail.smtp.smtptransport,sun microsystems, inc]} debug: loaded resource: /meta-inf/javamail.default.address.map debug: !anyloaded debug: not loading resource: /meta-inf/javamail.address.map debug: loaded file: c:\program files\java\jdk1.7.0_25\jre\lib\javamail.address.map debug: setdebug: javamail version 1.4ea debug: getprovider() returning javax.mail.provider[transport,smtps,com.sun.mail.smtp.smtpssltransport,sun microsystems, inc] debug smtp: useehlo true, useauth false debug smtp: trying connect host "smtp.gmail.com", port 465, isssl true 220 smtp.gmail.com esmtp xv9sm19052844pbc.2 - gsmtp debug smtp: connected host "smtp.gmail.com", port: 465 ehlo test 250-smtp.gmail.com @ service, [182.64.100.170] 250-size 35882577 250-8bitmime 250-auth login plain xoauth2 plain-clienttoken xoauth 250-enhancedstatuscodes 250-pipelining 250-chunking 250 smtputf8 debug smtp: found extension "size", arg "35882577" debug smtp: found extension "8bitmime", arg "" debug smtp: found extension "auth", arg "login plain xoauth2 plain-clienttoken xoauth" debug smtp: found extension "enhancedstatuscodes", arg "" debug smtp: found extension "pipelining", arg "" debug smtp: found extension "chunking", arg "" debug smtp: found extension "smtputf8", arg "" debug smtp: use8bit false mail from: 530-5.5.1 authentication required. learn more @ 530 5.5.1 https://support.google.com/mail/answer/14257 xv9sm19052844pbc.2 - gsmtp com.sun.mail.smtp.smtpsendfailedexception: 530-5.5.1 authentication required. learn more @ 530 5.5.1 https://support.google.com/mail/answer/14257 xv9sm19052844pbc.2 - gsmtp
at com.sun.mail.smtp.smtptransport.issuesendcommand(smtptransport.java:1388) @ com.sun.mail.smtp.smtptransport.mailfrom(smtptransport.java:959) @ com.sun.mail.smtp.smtptransport.sendmessage(smtptransport.java:583) @ edu.bhavesh.mail.smtp.ssl.sendmaildemo.sendsslmessage(sendmaildemo.java:135) @ edu.bhavesh.mail.smtp.ssl.sendmaildemo.main(sendmaildemo.java:41) com.sun.mail.smtp.smtpsendfailedexception: 530-5.5.1 authentication required. learn more @ 530 5.5.1 https://support.google.com/mail/answer/14257 xv9sm19052844pbc.2 - gsmtp quit
at com.sun.mail.smtp.smtptransport.issuesendcommand(smtptransport.java:1388) @ com.sun.mail.smtp.smtptransport.mailfrom(smtptransport.java:959) @ com.sun.mail.smtp.smtptransport.sendmessage(smtptransport.java:583) @ edu.bhavesh.mail.smtp.ssl.sendmaildemo.sendsslmessage(sendmaildemo.java:135) @ edu.bhavesh.mail.smtp.ssl.sendmaildemo.main(sendmaildemo.java:41) 221 2.0.0 closing connection xv9sm19052844pbc.2 - gsmtp
this properties needed gmail smtp, working it: using jars in classpath:
- mail.jar
- activation.jar
- additionnal.jar
commons-io-2.4.jar
string sendinghost = "smtp.gmail.com"; int sendingport = 465; properties props = new properties(); props.put("mail.smtp.host", sendinghost); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.port", sendingport + ""); /**add this**/ props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.starttls.required", "true"); props.put("mail.smtp.ssl", "true"); props.put("mail.smtp.ehlo", "true"); /** **/ session session = session.getdefaultinstance(props, new javax.mail.authenticator() { protected passwordauthentication getpasswordauthentication() { return new passwordauthentication(email.getfromaccount().getemail(), email.getfromaccount().getpassword()); } });
Comments
Post a Comment