How to check whether a SMTP server is supporting Authentication or not

Hi All,
We are using Java Mail API 1.3.1/1.3.2 to send the messages. some of the SMTP servers that we use are supporting authentication and some of them are not.
As the SMTPTransport.supportsAuthentication() is not available only in Java mail API 1.4.1, we are identifying the SMTP server whether it is supporting authentication or not in the following way.
Socket clientSocket = null;
InetSocketAddress socketAddress = null;
OutputStream outStream = null;
InputStream inStream = null;
InputStreamReader inReader = null;
OutputStreamWriter outWritter = null;
try
clientSocket = new Socket();
socketAddress = new InetSocketAddress(host, port);
clientSocket.connect(socketAddress, timeout*1000); // convert timeout from second to miliseconds
// 1: now try to execute the given command by passing that on Out-Socket
outStream = clientSocket.getOutputStream();
outWritter = new OutputStreamWriter(outStream);
outWritter.write("ehlo localhost" +"\n");
outWritter.flush();
// 2:Read output of above command
inStream = clientSocket.getInputStream();
inReader = new InputStreamReader(inStream);
// This array limit would be fine to get "AUTH" extension of smtp server.
char[] arr = new char[16384];
StringBuilder strBuilder = new StringBuilder();
inReader.read(arr);
for(int i=0; i< arr.length; i++)
strBuilder.append(arr);
System.out.println(METHOD_NAME + "SMTP server response for ehlo localhost command ->"+strBuilder.toString());
// The output EHLO command comes like below :
// ehlo localhost
// 250-ap9058pc.us.oracle.com Hello ap614ses.us.oracle.com [130.35.33.43], pleased to meet you
// 250-ENHANCEDSTATUSCODES
// 250-PIPELINING
// 250-8BITMIME
// 250-SIZE
// 250-DSN
// 250-ETRN
// 250-AUTH GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN
// Since for XATUH ( like internal IP),
// we are not sure, so just checking for AUTH capability.
supported = strBuilder.indexOf("250-AUTH") >=0? true : false;
As shown in above code, we are issuing 'ehlo localhost' command to SMTP server, if the response i. 'strBuilder' contains '250-AUTH' then we are assuming that it is supporting authentication.
But for one SMTP server the 'strBuilder' value is showing as '220 mail.durofelguera.com ESMTP Service (Lotus Domino Release 8.5.2) ready at Thu, 16 Feb 2012 13:57:20 +0100' only which is socket connection output but not 'ehlo localhost' command output.
where as the telnet test output is showing correct only as below
# telnet mail.durofelguera.com 25
Trying 172.20.16.65...
Connected to mail.durofelguera.com.
Escape character is '^]'.
220 mail.durofelguera.com ESMTP Service (Lotus Domino Release 8.5.2) ready
at 0
ehlo localhost
250-mail.durofelguera.com Hello localhost ([172.20.15.209]), pleased to meet
yu
250-HELP
250-AUTH LOGIN
250-SIZE
250 PIPELINING
AUTH LOGIN
The question is why the 'strBuilder' is not showing 'ehlo localhost' conad output where as the telnet test results are showing correctly, what is going wrong here?
Is there any other way to check that whether SMTP server is supporting authentication or not?
Edited by: sarojak on Feb 19, 2012 10:11 PM

There are so many things wrong with your code, it's hard to know where to start...
Basically, the problem is not as simple as you think it is.
For example, some servers might not allow authentication until you've issued
the STARTTLS command.
These days, essentially all servers allow authentication. You're probably better
off just assuming the server supports.

Similar Messages

  • How to check whether a Document in KM is classified or not using JAVA API

    Hello Everyone,
      Can anyone tell me, How to check whether a Document in KM is classified or not, using JAVA API's??
    Thanks & Regards,
    Adren D'Souza

    Hi,
    The code is as follows:
    IIndexService indexService = null;
    try {
       indexService = (IIndexService) ResourceFactory.getInstance().getServiceFactory().getService(IServiceTypesConst.INDEX_SERVICE);
    } catch (ResourceException e) {
       if (indexService == null) {
         log.errorT("Error on instanciating the index service");
         return this.renderMessage(this.getBundleString(RES_NO_INDEX_SERVICE), StatusType.ERROR);
    // get index
    IIndex index = null;
    try {
       index = indexService.getIndex("YourIndexID");
    } catch (WcmException e1) {
       log.errorT("Error when trying to get the index");
       return this.renderMessage(this.getBundleString(RES_NO_INDEX), StatusType.ERROR);
    // check if the index is a instance of AbstractClassificationIndex
    AbstractClassificationIndex classiIndex = null;
    if (index instanceof AbstractClassificationIndex) {
       classiIndex = (AbstractClassificationIndex) index;
    } else {
       log.errorT("The index " + index.getIndexName() + " is no classification index");
       return this.renderMessage(this.getBundleString(RES_NO_CLASSIFICATION_INDEX), StatusType.WARNING);
    //give your KM Resource here for which you want to know if it is classified or not
    boolean classified = classiIndex.isDocClassifiedInAnyTax(resource);
    Regards,
    Praveen Gudapati

  • How to check whether my iphone 5 is factory unlocked or not??

    how to check whether my iphone 5 is factory unlocked or not??

    Did you buy it unlocked at full, non-subsidised price?  If not, then it's not unlocked.

  • How to check whether the Application Server directory exits or not

    Hi,
    I have a selection screen in which I give the Application server file name(UNIX file) as input. Here, I would like to check whether the Server directory exists or not.
    Let us say, the path I gave in the selection screen is /usr/sap/tmp/testfile.txt . Here, the file name is testfile.txt and the server directory is /usr/sap/tmp . I would like to check whether this directory /usr/sap/tmp exists in the server or not. I am not bothered about the file name as I am going to write data into the file. I am mainly concerned about whether the directory exists in the server or not. and one more thing... this is the Application Server path not the Local path.
    Can anyone help me on the same how to check whether the server directory exists or not.
    Thanks in advance.
    Best Regards,
    Pradeep.

    Also you can use the FM EPS_GET_DIRECTORY_LISTING for this purpose.
      Store the directory name
        l_dpath = p_file+0(l_no).
      Validate the directory of the application server
        CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
          EXPORTING
            dir_name               = l_dpath
          TABLES
            dir_list               = l_i_dlist
          EXCEPTIONS
            invalid_eps_subdir     = 1
            sapgparam_failed       = 2
            build_directory_failed = 3
            no_authorization       = 4
            read_directory_failed  = 5
            too_many_read_errors   = 6
            empty_directory_list   = 7
            OTHERS                 = 8.
      If any problem occurs with the directory then display proper
      error message
        IF sy-subrc <> 0.
        Display error message
          MESSAGE e018 WITH 'Problem with directory entered'(008).
        ENDIF. " sy-subrc <> 0
    Regards,
    Joy.

  • How to check whether a Oracle server is installed or not ?

    Hi,
    How cani check whether a Machine has oracle server installed or not ?
    I have a machine where i have the client tools installed but not server. In that case how can i check whether this machine has oracle server is installed or not?
    Thanks in Advance..

    user11000236 wrote:
    Hi,
    How cani check whether a Machine has oracle server installed or not ?
    I have a machine where i have the client tools installed but not server. In that case how can i check whether this machine has oracle server is installed or not?
    Thanks in Advance..http://tinyurl.com/ngunhv
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

  • How to check whether a char string is in uppercase or not

    Hi,
    I know how to convert strings to change strings to uppercase or lowercase, but is there any function to check, beforehand, if the field is in uppercase, for instance ? The intention here is simply to spare processing in situations where the string is already in uppercase, and thus not needing any further processing (given I want to turn the string into uppercase.)
    Thanks in advance,
    Avraham

    Hi Avraham ,
    To check whether the string is in upper case or not use CA keyward.
    To check  try the following code  ---
    DATA : W_STRING(5) TYPE C,
    W_ABCDE(26) TYPE C VALUE 'abcdefghijklmnopqrstuvwxyz'.
    w_string = 'abcd'.
    IF W_STRING CA W_ABCDE.
    TRANSLATE w_string TO UPPER CASE.
    ELSE.
    MESSAGE 'It is a uppercase string' TYPE 'S'.
    ENDIF.
    Try this link  this will definitely help you -
    https://wiki.sdn.sap.com/wiki/display/ABAP/Validationofastringintermsof+case
    Regards
    Pinaki

  • How to check whether java.sql.Connection has been dropped or not

    Hi,
    How can i check whether the connection is dropped from the database or not by using java.sql.Connection API.
    Thanks

    There's a few ways to check Connections, each with a different use:
    (1) conn.isOpen()
    (2) conn == null
    (3) the last one is a little more involved and adds some overhead. You can run SELECT 1 FROM dual; (Oracle) or SELECT 1 (MSSQL) and check for exceptions.
    The only way to check a connection, as far as I know, is to use it. That said, there must be a better way???

  • How to check whether the Application Server file has already been opened?

    Hi Experts,
    I have a query related to Application Server file. I am using multithreading concept to process the data and write it in to a single file.
    For example, I have 4 workprocesses. Each workprocess will process the data and whenever it has a record available it will access the file and write it directly.
    Problem is the statements that are written in the workprocess is same and I want to check the status whether the file has been opened or not ?
    Thanks in advance!!!
    Thanks,
    Babu Kilari

    Depends on the structure, and whether the data needs to be sorted in some way in the final file.
    In any case, I don't think there will be a significant performance difference between using OPEN DATASET again and getting funny with Unix commands.
    If you don't need to sort the final file, you can use strings to read, concatenate and write the data even without line-based DO ENDDO loops, this works pretty fast.
    I hope we are not talking about GBytes of data
    Thomas

  • How to check whether campaign has been uploaded to online server

    Hi,
    How to check whether campaign has been uploaded to online server by using SQL analyzer
    Thanks,
    Rasheed

    Hi Rasheed,
    To quickly check if the campaign has been uploaded from MSA to the server, you can check the TR_STATUS column on the SMOPCCAMPN table for your campaign, if the value is P000 or P*** then it has been uploaded to the server and is waiting for confirmation, if the status is O, it has been uploaded and created in the server.
    Best Regards,
    Ankan

  • How to check whether User is alreadylogged in or not

    Hi..I want to check whether Particular User is already logged in or not ?? I had userid,password and status in my database.
    If anybody shows me how to implement it ??
    Reggards
    Chintan

    If you want to prevent multiple logins happening, use a profile on the database server that limits a login to a set number of simultaneous connections.
    If you just ant to check which users are logged in, the v$session table will have that information.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • How to check Whether the File is in Progress or used by some other resource

    Hi All,
    I am retrieving a file from the FTP server using Apache commons FTP.
    I need to check whether the file is fully retrieved or in progress.
    for now i can able to use the file which is partially retrieved. it is not throwing any file sharing exception or i am unable to find whether it is in progress.
    How to check whether the file is in progress ? or The file is accessed by some other resource ?
    Pls Help me.
    Thanks,
    J.Kathir

    Hi Vamsi,
    Explicitly such kind of requirement has not been catered and i dont think you would face a problem because any application that is writing to a file will open the file in the read only mode to any other simultaneous applications so i think your concerns although valid are already taken care off .
    In the remote case you still face a problem then as a work around. Tell the FTP administrator to set the property to maximum connections that can be made to ftp as one. I wonder if you have heard of the concept of FTP handle , basically the above workaround is based on that concept itself. This way only one application will be able to write.
    The file adapter will wait for its turn and then write the files.
    Regards
    joel
    Edited by: joel trinidade on Jun 26, 2009 11:06 AM

  • How to check whether Output ES is working or not.

    I am able to see Output ES in the services list of the admin console of my server. Please let me know how to check whether this is working or not.
    Regards,
    Shabeer

    LiveCycle ES2 (and LiveCycle ES) ship with three undersold and unadvertised web applications that are VERY useful. Each is referred to as an Installation Verification Sample (or IVS) but they are great testing tools you can use during development and QA. There is
    1) Assembler IVS,
    2) Forms IVS, and
    3) Output IVS
    Output IVS looks like this...
    The pattern for deploying and using all three IVSs is very similar as what I am about to describe for Output IVS. The following directions apply to the JBoss turnkey on Windows.
    1) go to C:\Adobe\Adobe LiveCycle ES2\deploy and locate adobe-output-ivs-jboss.ear
    2) copy adobe-output-ivs-jboss.ear to C:\Adobe\Adobe LiveCycle ES2\jboss\server\lc_turnkey\deploy
    3) if necessary, start LiveCycle
    4) open a browser and go to http://localhost:8080/OutputIVS/
    5) click Check/Change your preferences
    6) add Admin Credentials
    7) click Save
    8) click Test your form designs
    9) Select an .xdp from Form designs
    10) Click Use EJB (or Use Web Service if you feel so inclined) to invoke LiveCycle Output ES2
    Steve

  • R12.1.1 staging complete! How to check whether the stage is Good

    Hi Gurusl,
    I have completed staging R12.1.1 for Hp unix B.11.31. I want to know how to check whether the stage is good for installation or whether it is corrupted. Is there any metalink note or script from where we can check it. Ur help will be highly appreciated. Thanks in advance
    regards,

    Hi,
    Please refer to (Note: 802195.1 - MD5 Checksums for R12.1.1 Rapid Install Media).
    Regards,
    Hussein

  • How to check whether transport path exist between two systems in sld??

    Hi,
         I have two systems namely 'A' and 'B' and created business systems for both of them.Then i created transport path between the two systems.How i check whether what i have done is right in SLD.

    <b>WRT to CMS</b>
    am not sure with this but u can try:
    1. Start CMS: http://<host>:<J2EE Engine http port>/webdynpro/dispatcher/sap.com/tcSLCMS~WebUI/Cms.
    2. Goto lansdscape configurator and check there
    Message was edited by:
            Prabhu  S

  • How to check whether follow on document is created for sc or po,is there any table or fm available?

    How to check whether follow on document is created for sc or po,is there any table or fm available?

    Hello Venu
    Check FM: BBP_PD_SC_GETDETAIL and BBP_PD_PO_GETDETAIL table E_HEADER_REL
    Check this: SRM Shopping cart and PO tables link
    Regards

Maybe you are looking for

  • Is there a way to use a non-apple external display (monitor) without having my macbook air plugged in?

    Just got a 27'' AOC monitor that I'm using with my Macbook Air (purchased in 2013). It's working great but as soon as I unplug the power adapter from my laptop the monitor goes black and says 'no signal'. I've been reading online that you need to hav

  • Cannot open itunes after download

    I just bought my nano ipod. i downloaded everything as instructed;however, when i clicked on the itunes icon to open it--the agreement consent form pops up and disappears before i can click anything! also, the quicktime player pops up and then dissap

  • 1366 x 768 resolutions on titan 700

    Hello, how can I set the 1366 x 768 resolutions on my Titan 700? Thanks for your co-operation Marco

  • UME ABAP Error in Backend Service

    Hi Everyone, We are having problems with an ABAP based UME on EP7. SSO is working and when we create users in R/3(ECC 6.0) we can immediately use them to log on to the portal. However, when we go to User Administration --> Identity Management on the

  • Can't open mail after update

    I am getting an error message saying that mail can't open because the newer version may be located elsewhere than in applications.  I have checked and I have versions 4.5 and 4.6 in applications.  I have followed instructions in help to reinstall Mac