Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8266787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:17:13+00:00 2026-06-08T05:17:13+00:00

I have a sample gmail client class. In that class I initialize BOTH IMAPS

  • 0

I have a sample gmail client class. In that class I initialize BOTH IMAPS & SMTPS sessions.
For some time it was working fine. But now Gmail throws SMTO Send Fail Exception.

Here is how I connect to Gmail via javamail..

//String smtpHost = "imap.gmail.com";
//String imapHost = "smtp.gmail.com";
//String userName = "XXXXXX@gmail.com";
//String userPass = "PASSWORD";
//Properties props = new Properties();


public DirectMailBox(String smtpHost, String imapHost, String userName,
        String userPass, Properties props) throws MessagingException {
    super();
    this.imapHost = imapHost;
    this.smtpHost = smtpHost;
    this.userName = userName;
    this.userPass = userPass;
    this.props = props;

    session = Session.getDefaultInstance(props);
    session.setDebug(true);
    imapsStore = session.getStore("imaps");
    imapsStore.connect(imapHost, userName, userPass);

    smtpsTransport = session.getTransport("smtps");
    smtpsTransport.connect(smtpHost, userName, userPass);
    smtpsTransport.addTransportListener(this);
}

and here is how I call sendmail..

public void sendMail(MimeMessage newMessage) throws MessagingException {
    smtpsTransport.sendMessage(newMessage, newMessage.getAllRecipients());
}

Followed Instructions on this URL but no solution.
http://support.google.com/mail/bin/answer.py?answer=14257

Here is a debug Dump…..

DEBUG: setDebug: JavaMail version 1.4ea
DEBUG: getProvider() returning javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc]
DEBUG: mail.imap.fetchsize: 16384
* OK Gimap ready for requests from 14.140.225.250 uy8if8067087pbc.8
A0 CAPABILITY
* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH
A0 OK Thats all she wrote! uy8if8067087pbc.8
IMAP DEBUG: AUTH: XOAUTH
DEBUG: protocolConnect login, host=smtp.gmail.com, user=XXXXXX@gmail.com, password=<non-null>
A1 LOGIN XXXXXX@gmail.com PASSWORD
* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE
A1 OK XXXXXX@gmail.com Rakesh Waghela authenticated (Success)
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 to connect to host "imap.gmail.com", port 465, isSSL true
220 mx.google.com ESMTP mt9sm3371719pbb.14
DEBUG SMTP: connected to host "imap.gmail.com", port: 465

EHLO LPT0031
250-mx.google.com at your service, [14.140.225.250]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH
250 ENHANCEDSTATUSCODES
DEBUG SMTP: Found extension "SIZE", arg "35882577"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN XOAUTH"
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG: setDebug: JavaMail version 1.4ea
DEBUG: getProvider() returning javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc]
DEBUG: mail.imap.fetchsize: 16384
* OK Gimap ready for requests from 14.140.225.250 vf8if4407540pbc.7
A0 CAPABILITY
* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH
A0 OK Thats all she wrote! vf8if4407540pbc.7
IMAP DEBUG: AUTH: XOAUTH
DEBUG: protocolConnect login, host=smtp.gmail.com, user=XXXXXX@gmail.com, password=<non-null>
A1 LOGIN XXXXXX@gmail.com PASSWORD
* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE
A1 OK XXXXXX@gmail.com Rakesh Waghela authenticated (Success)
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 to connect to host "imap.gmail.com", port 465, isSSL true
220 mx.google.com ESMTP ru4sm3359950pbc.66
DEBUG SMTP: connected to host "imap.gmail.com", port: 465

EHLO LPT0031
250-mx.google.com at your service, [14.140.225.250]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH
250 ENHANCEDSTATUSCODES
DEBUG SMTP: Found extension "SIZE", arg "35882577"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN XOAUTH"
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: use8bit false
MAIL FROM:<RakeshW@LPT0031>
530-5.5.1 Authentication Required. Learn more at
530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 mt9sm3371719pbb.14
com.sun.mail.smtp.SMTPSendFailedException: 530-5.5.1 Authentication Required. Learn more at
530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 mt9sm3371719pbb.14

    at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1388)
    at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:959)
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:583)
    at com.wellogic.phoenix.mail.direct.DirectMailBox.sendMail(DirectMailBox.java:86)
    at com.wellogic.phoenix.test.DirectMailTest.testSendMail(DirectMailTest.java:40)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Not Delivered...
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T05:17:15+00:00Added an answer on June 8, 2026 at 5:17 am

    Finally resolved the issue..!! Using following method.

    http://mlusincuba.wordpress.com/2012/03/03/java-mail-gmail-smtp-client/

    package com.mycompany.employee.utils;
    
    import java.io.UnsupportedEncodingException;
    import java.util.Properties;
    import javax.mail.Message;
    import javax.mail.MessagingException;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeMessage;
    
    /**
     * @author Mlungisi
     *
     */
    public class GMail {
    
        public static void sendMail(String senderEmail, String recipientEmail, String subject, String message) throws MessagingException, UnsupportedEncodingException {
    
            // SSL // I USED THIS METHOD            
            Properties propsSSL = new Properties();
    
            // EVEN IF YOU SKIP THESE TWO PROP IT WOULD WORK
            propsSSL.put("mail.transport.protocol", "smtps");
            propsSSL.put("mail.smtps.host", "smtp.gmail.com");
    
            // THIS IS THE MOST IMPORTANT PROP --> "mail.smtps.auth"
            propsSSL.put("mail.smtps.auth", "true");
    
            Session sessionSSL = Session.getInstance(propsSSL);
            sessionSSL.setDebug(true);
    
            Message messageSSL = new MimeMessage(sessionSSL);
            messageSSL.setFrom(new InternetAddress("yourgmail@gmail.com", "Mlungisi Sincuba"));
            messageSSL.setRecipients(Message.RecipientType.TO, InternetAddress.parse("yourgmail@gmail.com")); // real recipient
            messageSSL.setSubject("Test mail using SSL");
            messageSSL.setText("This is test email sent to Your account using SSL.");
    
            Transport transportSSL = sessionSSL.getTransport();
            // EVEN IF YOU SKIP PORT NUMBER , IT WOULD WORK
            transportSSL.connect("smtp.gmail.com", 465, "yourgmail@gmail.com", "yourpassword"); // account used
            transportSSL.sendMessage(messageSSL, messageSSL.getAllRecipients());
            transportSSL.close();
    
            System.out.println("SSL done.");
        }
    
        public static void main(String[] args) throws MessagingException, UnsupportedEncodingException {
            System.out.println("Hello World!");
            sendMail(null, null, null, null);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've started working on a little ruby project that will have sample implementations of
I am working on Email client application. I have written one sample program for
I have a sample class where I need to specialize the Print function if
I have a sample code: <table id=modem_list> <tr class=input_1 name=modem> <td>iPad 1<input type=hidden value=1
I have implemented a C2DM client that requests the registration id from C2DM server.
I have this sample data akb.ggb@yahoo.com should output akb ggb sdsd.sdsd@gmail.com should output sdsd
I'm wondering how it's implemented in Gmail, that every time you receive e-mail, the
I have a application that has a text field, something like a sample notepad
I have some sample code which is using factories. I'd like to clean up
I have noticed that some of my ajax-heavy sites (ones I visit, not ones

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.