Thursday, August 7, 2014

Using GMail's SMTP and IMAP servers in Oracle Notification Mailer (Workflow Mailer )


Hi All ...
Here the step by step guide how to use Gmail account  with Oracle Workflow mailer.
Tested it in couple of customer sites and it working perfect...

Overview
GMail offers free, reliable, popular SMTP and IMAP services, because of which many people are interested to use it. GMail can be used when there are no in-house SMTP/IMAP servers for testing or debugging purposes. This blog explains how to install GMail SSL certificate in Concurrent Tier, testing the connection using a standalone program, running Mailer diagnostics and configuring GMail IMAP and SMTP servers for Workflow Notification Mailer Inbound and Outbound connections.

GMail servers configuration

SMTP server 

Host Name smtp.gmail.com
SSL Port 465
TLS/SSL required Yes
User Name Your full email address (including @gmail.com or @your_domain.com)
Password Your gmail password

 IMAP server

 Host Nameimap.gmail.com 
 SSL Port993 
TLS/SSL Required Yes 
 User Name Your full email address (including @gmail.com or @your_domain.com)
 PasswordYour gmail password

GMail SSL Certificate Installation

The following is the procedure to install the GMail SSL certificate
  • Copy the below GMail SSL certificate in to a file eg: gmail.cer
    -----BEGIN CERTIFICATE-----
    MIIDWzCCAsSgAwIBAgIKaNPuGwADAAAisjANBgkqhkiG9w0BAQUFADBGMQswCQYD
    VQQGEwJVUzETMBEGA1UEChMKR29vZ2xlIEluYzEiMCAGA1UEAxMZR29vZ2xlIElu
    dGVybmV0IEF1dGhvcml0eTAeFw0xMTAyMTYwNDQzMDRaFw0xMjAyMTYwNDUzMDRa
    MGgxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1N
    b3VudGFpbiBWaWV3MRMwEQYDVQQKEwpHb29nbGUgSW5jMRcwFQYDVQQDEw5pbWFw
    LmdtYWlsLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAqfPyPSEHpfzv
    Xx+9zGUxoxcOXFrGKCbZ8bfUd8JonC7rfId32t0gyAoLCgM6eU4lN05VenNZUoCh
    L/nrX+ApdMQv9UFV58aYSBMU/pMmK5GXansbXlpHao09Mc8eur2xV+4cnEtxUvzp
    co/OaG15HDXcr46c6hN6P4EEFRcb0ccCAwEAAaOCASwwggEoMB0GA1UdDgQWBBQj
    27IIOfeIMyk1hDRzfALz4WpRtzAfBgNVHSMEGDAWgBS/wDDr9UMRPme6npH7/Gra
    42sSJDBbBgNVHR8EVDBSMFCgTqBMhkpodHRwOi8vd3d3LmdzdGF0aWMuY29tL0dv
    b2dsZUludGVybmV0QXV0aG9yaXR5L0dvb2dsZUludGVybmV0QXV0aG9yaXR5LmNy
    bDBmBggrBgEFBQcBAQRaMFgwVgYIKwYBBQUHMAKGSmh0dHA6Ly93d3cuZ3N0YXRp
    Yy5jb20vR29vZ2xlSW50ZXJuZXRBdXRob3JpdHkvR29vZ2xlSW50ZXJuZXRBdXRo
    b3JpdHkuY3J0MCEGCSsGAQQBgjcUAgQUHhIAVwBlAGIAUwBlAHIAdgBlAHIwDQYJ
    KoZIhvcNAQEFBQADgYEAxHVhW4aII3BPrKQGUdhOLMmdUyyr3TVmhJM9tPKhcKQ/
    IcBYUev6gLsB7FH/n2bIJkkIilwZWIsj9jVJaQyJWP84Hjs3kus4fTpAOHKkLqrb
    IZDYjwVueLmbOqr1U1bNe4E/LTyEf37+Y5hcveWBQduIZnHn1sDE2gA7LnUxvAU=
    -----END CERTIFICATE-----
    • Install the SSL certificate into the default JRE location or any other location using below command
    • Installing into a dfeault JRE location in EBS instance
            # keytool -import -trustcacerts -keystore $AF_JRE_TOP/lib/security/cacerts  -storepass changeit -alias gmail-lnx_chainnedcert -file gmail.cer
    • Install into a custom location
            # keytool -import -trustcacerts -keystore <customLocation>  -storepass changeit -alias gmail-lnx_chainnedcert -file gmail.cer
           <customLocation> -- directory in instance where the certificate need to be installed
    • After running the above command you can see the following response
            Trust this certificate? [no]:  yes
            Certificate was added to keystore 

    Running Mailer Command Line Diagnostics

    • Run Mailer command line diagnostics from conccurrent tier where Mailer is running, to check the IMAP connection using the below command
    $AFJVAPRG -classpath $AF_CLASSPATH -Dprotocol=imap -Ddbcfile=$FND_SECURE/$TWO_TASK.dbc -Dserver=imap.gmail.com -Dport=993 -Dssl=Y -Dtruststore=$AF_JRE_TOP/lib/security/cacerts -Daccount=<gmail username> -Dpassword=<password> -Dconnect_timeout=120 -Ddebug=Y -Dlogfile=GmailImapTest.log -DdebugMailSession=Y oracle.apps.fnd.wf.mailer.Mailer
    • Run Mailer command line diagnostics from concurrent tier where Mailer is running, to check the SMTP connection using the below command  
     $AFJVAPRG -classpath $AF_CLASSPATH -Dprotocol=smtp -Ddbcfile=$FND_SECURE/$TWO_TASK.dbc -Dserver=smtp.gmail.com -Dport=465 -Dssl=Y -Dtruststore=$AF_JRE_TOP/lib/security/cacerts -Daccount=<gmail username> -Dpassword=<password> -Dconnect_timeout=120 -Ddebug=Y -Dlogfile=GmailSmtpTest.log -DdebugMailSession=Y oracle.apps.fnd.wf.mailer.Mailer 

    Standalone program to verify the IMAP connection

    Run the below standalone program from the concurrent tier node where Mailer is running to verify the connection with GMail IMAP server. It connects to the GMail IMAP server with the given GMail user name and password and lists all the folders that exist in that account. If the GMail IMAP server is not working for the  Mailer check whether the PROCESSED and DISCARD folders exist for the GMail account, if not create manually by logging into GMail account.
    Sample program to test GMail IMAP connection
     The standalone program can be run as below
     $java GmailIMAPTest GMailUsername GMailUserPassword           

    Standalone program to verify the SMTP connection

    Run the below standalone program from the concurrent tier node where Mailer is running to verify the connection with GMail SMTP server. It connects to the GMail SMTP server by authenticating with the given user name and password  and sends a test email message to the give recipient user email address.
    Sample program to test GMail SMTP connection
    The standalone program can be run as below 
     $java GmailSMTPTest GMailUsername GMailPassword recipientEmailAddress   

    Warnings

    • As gmail.com is an external domain, the Mailer concurrent tier should allow the connection with GMail server
    • Please keep in mind when using it for corporate facilities, that the e-mail data would be stored outside the corporate network
    Good Luck ...

    No comments:

    Post a Comment