PL/SQL and Google POP server

Hi,
With the help of Billy's code and a little editing of my own, I am able to retrieve the emails from the POP server with the attachments in correct format. Now I am trying to connect to the POP mail server located on one of our company's server.
My code is as follows :
CREATE OR REPLACE FUNCTION pop3 (
username VARCHAR2,
PASSWORD VARCHAR2,
msgnum NUMBER
RETURN tstrings PIPELINED
IS
pop3_server CONSTANT VARCHAR2 (100) := '192.168.0.3';
pop3_port CONSTANT NUMBER := 995;
pop3_ok CONSTANT VARCHAR2 (10) := '+OK';
e_pop3_error EXCEPTION;
socket UTL_TCP.connection;
line VARCHAR2 (30000);
BYTES INTEGER;
-- send a POP3 command
-- (we expect each command to respond with a +OK)
FUNCTION writetopop (command VARCHAR2)
RETURN VARCHAR2
IS
len INTEGER;
resp VARCHAR2 (30000);
BEGIN
len := UTL_TCP.write_line (socket, command);
UTL_TCP.FLUSH (socket);
-- using a hack to check the popd response
len := UTL_TCP.read_line (socket, resp);
IF SUBSTR (resp, 1, 3) != pop3_ok
THEN
RAISE e_pop3_error;
END IF;
RETURN (resp);
END;
BEGIN
PIPE ROW ('pop3:' || pop3_server || ' port:' || pop3_port);
-- Just to make sure there are no previously opened connections
UTL_TCP.close_all_connections;
-- open a socket connection to the POP3 server
socket :=
UTL_TCP.open_connection (remote_host => pop3_server,
remote_port => pop3_port,
--tx_timeout => POP3_TIMEOUT,
CHARSET => 'US7ASCII'
-- read the server banner/response from the pop3 daemon
PIPE ROW (UTL_TCP.get_line (socket));
-- authenticate with the POP3 server using the USER and PASS commands
PIPE ROW ('USER ' || username);
PIPE ROW (writetopop ('USER ' || username));
PIPE ROW ('PASS ' || PASSWORD);
PIPE ROW (writetopop ('PASS ' || PASSWORD));
-- retrieve the specific message
PIPE ROW ('RETR ' || msgnum);
PIPE ROW (writetopop ('RETR ' || msgnum));
--PIPE ROW( 'LIST '||msgNum ); PIPE ROW( WriteToPop('LIST '||msgNum) );
PIPE ROW ('*** START OF INTERNET MESSAGE BODY ***');
LOOP
BYTES := UTL_TCP.available (socket);
IF BYTES > 0
THEN
BYTES := UTL_TCP.read_line (socket, line);
line := REPLACE (line, CHR (13) || CHR (10), '');
-- WILL HAVE TO USE PLSQL FUNCTIONS (HAVE BOOKMARKED) TO GET THE MAIL
-- IN THE PREFERRED FORMAT. CAN USE "REPLACE()"
          -- Checking end of email
IF LENGTH (line) = 1 AND line = '.'
THEN
PIPE ROW ('*** END OF INTERNET MESSAGE BODY ***');
ELSE
PIPE ROW (line);
END IF;
END IF;
EXIT WHEN LENGTH (line) = 1 AND line = '.';
END LOOP;
-- close connection
PIPE ROW ('QUIT');
PIPE ROW (writetopop ('QUIT'));
UTL_TCP.close_connection (socket);
EXCEPTION
WHEN e_pop3_error
THEN
PIPE ROW ('There are no mails !');
END;
On running this code in the following manner :
SQL> select * from table(pop3('[email protected]','my_passwd',1));
I get the error msg as:
ERROR:
ORA-29260: network error: TNS:no listener
ORA-06512: at "SYS.UTL_TCP", line 17
ORA-06512: at "SYS.UTL_TCP", line 246
ORA-06512: at "SCOTT.POP3", line 42
I have checked my Microsoft Outlook settings and they are as follows :
Incoming server (POP3) : 995
This server requires Encrypted Connection(SSL).
Outgoing server (SMTP) : 587
Use the following type of encryted connection: TLS
Can someone please provide me some solution to my problem.
P.S. : 192.168.0.3 is the machine that is hosting Gmail POP3 server (pop.gmail.com). I have already tried giving "pop.gmail.com" for server name (pop3_server) in the above code. In that case it gives me error:
ERROR:
ORA-29259: end-of-input reached
ORA-06512: at "SYS.UTL_TCP", line 116
ORA-06512: at "SYS.UTL_TCP", line 310
ORA-06512: at "SYS.UTL_TCP", line 380
ORA-06512: at "SCOTT.POP3", line 49
Also, when i telnet to pop.gmail.com, the command prompt goes blank and does not display anything that i type and in about 5 seconds shows the normal command prompt with default route. Whereas, telnet to 192.168.0.3 gives me error "Could not open connection to the host, on port 995: Connect failed".

You need the last 11.2.0.2.0 DB. In that version utl_tcp.open_connection has two new parameters, wallet_path and wallet_password. You have to create a new Wallet using wallet manager and import the certificate from pop.gmail.com or whatever server you want to connect to using SSL.
Then your code would be:
CREATE OR REPLACE PROCEDURE pProcesarPOP3 IS
lvcServidor CONSTANT VARCHAR2(50) := 'pop.gmail.com';
lvcUsr CONSTANT VARCHAR2(100) := '<username>';
lvcPwd CONSTANT VARCHAR2(100) := '<password>';
lncPuerto CONSTANT PLS_INTEGER := 995;
ltSocket utl_tcp.connection;
BEGIN
-- crea el socket hacia el servidor POP3
ltSocket := utl_tcp.open_connection(lvcServidor, lncPuerto, NULL, NULL, 10000, 10000, 'US7ASCII', NULL, 5,
'file:<wallet_path>', '<wallet_passwd>');
-- SSL
utl_tcp.secure_connection(ltSocket);
-- bienvenida servidor
lvLinea := utl_tcp.get_line(ltSocket);
-- veriifica éxisto de la conexión
IF (SUBSTR(lvLinea, 1, 3) != '+OK') THEN
dbms_output.put_line('ERR: '||lvLinea);
RETURN;
[...]

Similar Messages

  • Integration of PL/SQL and JSP (Java Server Pages)

    I need to match a web application developed with PL/SQL with another developed in JSP (Java Server Pages) the problem is that the two apps interact with the same databese, an share de same users, I need to know how to get the user and password loged into pl/sql when the user want to use same of de .jsp pages running on another application server?

    Hi Michael Vstling,
    Did you try the java classes library (SDOAPI) that can be downloaded from OTN?
    It may provide you with a better alternative when manipulating geometries in the Java space. There is an adapter in SDOAPI which can convert a JDBC STRUCT object into Java Geometry object defined in SDOAPI, and vice versa.
    There are at least two ways in mixing PL/SQL and Java. The first one, as you mentioned, is to define your custom function in terms of PL/SQL and call it from within your Java program. With SDOAPI, you have the second option, which is to define your own functions in Java using SDOAPI and deploy them as Java stored procedures in db. You can then call them from within your PL/SQL code. In either way performance depends on a lot of things and generally it requires a "try and improve" approach.
    About JPublisher and sdo_ordinate_array it may not be a spatial related problem. Did you try search the Java-related forums first?
    LJ

  • Web Application need to merge SQL and PDF on Server

    I have written a internal web application .aspx using Acrobat Pro 9 and LifeCycle.  I am using a California State PDF form that I cannot alter and merging data from SQL and an input form to produce the final PDF file.  The application works great on the development server where the software is installed. The issue I am having is that I want my users to access the web application from their personal PC's in the office to great it and it appears that I need to have Acrobat Pro 9 installed on their desktops.  This is not an acceptable solution for my 120 users.  Is there anyway I can create the final pdf on the server and just provide them with a directory of the final document?    This is my first application using Pro 9 and Life Cycle and really need anyone's help.  Can Pro 9 even do this on the server ?

    One of this:
    http://forums.adobe.com/community/livecycle/livecycle_es
    You can't use LiveCycle Designer or Adobe Acrobat on a server.

  • CRM 5.0 Installation with MS-SQL and windows 2003 server

    Hi,
    I have to install CRM 5.0 with MS-SQL 2005 and ECC 6.0 with Oracle 10g and integrate with QAS(Third party tool).
    My question are:
    1.Can we install all there application on single server.
    2. what s/w units we have to chose generally and what are standard(ie. EP,TREX etc.....)
    3.Can we install the s/w units later after CRM core installation.
    I am a BASIS Consulatnt and first time installing the CRM.
    Regards
    Alok

    Hi Alok,
    1. You can install all the applications in one box, But it is not advisable as the performance of all the applications can degrade.
    2. Software units like EP, Trex are installed based on the business needs, requirements...
    3. You can proceed initially with the installation of CRM Core components and later you can install other components/ software units.
    Thanks
    Ashok. R

  • Trying to open and Google imap server is rejecting my password

    I keep getting hacked and decided to set up all my appliances with 2 step verification.  Now I am locked out of my gmail account on my computer.  the imap server box keeps appearing asking for my password but rejects it when I enter it.  What is my next step?

    Did you actually "Make the move" to iCloud? You have to manually do that to transition from MobileMe.

  • Mail doesn't put relevant conversations into a conversation. Could this be due to using hotmail and therefore a POP server?

    I recently downloaded Lion and was wondering why the conversations in mac mail wasn't working properly. My relpy to the message goes into the conversation, but then the reply from the other person opens as a new message not in the same conversation. Is there a setting I am unaware of?
    Could this be becasue I use hotmail and a pop server?

    No, this is because Mail is programmed with rigid, inappropriate rules for grouping messages in conversations. There are no settings that can modify either the rules for grouping or the grouping after applying the rules.  Mail  thinks it's smarter than you are and won't listen to any arguments to the contrary.

  • Pop Server Rejects Password Issue

    I continuously get "Enter Password for Account ..." and "the pop server XXX rejected the password for user YYY".
    I have searched for this online and have seen some threads on this, most of which have closed without resolution.
    I'm raising it again as I think this issue is related to owning an iPhone and I have not seen that discussed anywhere at this point.
    My Wife and I both use the same service provider for email. Last year I bought her a iPhone and the password rejections started on her account only. I didn't pay much notice at the time as this didn't affect my account! To her credit it was she that spotted the relationship with the iPhone.
    This year I bought the new 3GS iPhone and immediately I start to get the pop server rejection messages.
    Can anyone help with this mildly irritating issue?

    Does this help (temporarily?)
    This might be due to one of Leopards most serious bug.
    The one that makes Mail randomly switch setting in "Account<Advanced<Authentification"
    from "Password to APOP"
    If the setting has been changed to APOP you will be asked for a password.
    Change back to Password and all is well until the next time Mail suddenly and unexpectedly changes the setting all by itself.
    But of course, this depends on what settings your provider is using.
    Michael

  • TS3276 Mail keeps checking a pop server related to an account I deleted.

    Dear Friends,
    A few months ago I upgraded to Lion and all Mail accounts were moved to the new version of Mail.
    A couple of weeks after I deletes the pop account related to my company web server. All the messages not moved to different folder were deleted and the pop server and SMTP server 10.1.11.100 disappeared from the server list.
    I realized from the "Activity" window that Mail keeps checking it for new e-mail.
    I deleted Mail's preference file without success. I searched with spotlight for an occurrence of "10.1.11.100" in files and system files without any result.
    Is there any further step I can take to stop Mail from checking this server that doesn't exist anymore?
    Many thanks in advance!
    Regards,
    lS.

    Check the smtp outgoing server list and see if one still exists for that account. If so, delete it.

  • Hi I have two macbook pro, i connected one from another via lan cable , now when i removed it, its showing me some pop up again and again saying server may not exists and there was a problem connecting to ishan's macbook pro

    Hi I have two macbook pro, i connected one from another via lan cable , now when i removed it, its showing me some pop up again and again saying server may not exists and there was a problem connecting to ishan's macbook pro

    If you just reboot it, does the problem go away?

  • How to Perform Forced Manual Failover of Availability Group (SQL Server) and WSFC (Windows Server Failover Cluster)

    I have a scenario with the three nodes with server 2012 standard, each running an instance of SQL Server 2012 enterprise, participate in a
    single Windows Server Failover Cluster (WSFC) that spans two data centers.
    If the nodes in the primary data center are unavailable due to data center outage. Then how I can able to access node in the WSFC (Windows Server Failover Cluster) in the secondary disaster recovery data center automatically with some script.
    I want to write script that can be able to check primary data center by pinging some IP after every 5 or 10 minutes.
    If that IP is unable to respond then script can be able to Perform Forced Manual Failover of Availability Group (SQL Server) and WSFC (Windows Server Failover Cluster)
    Can you please guide me for script writing for automatic failover in case of primary datacenter outage?

    please post you question on failover clusters in the cluster forum.  THey will explain how this works and point you at scipts.
    You should also look in the Gallery for cluster management scripts.
    ¯\_(ツ)_/¯

  • How to Perform Forced Manual Failover of Availability Group (SQL Server) and WSFC (Windows Server Failover Cluster) with scrpiting

    I have a scenario with the three nodes with server 2012 standard, each running an instance of SQL Server 2012 enterprise, participate in a
    single Windows Server Failover Cluster (WSFC) that spans two data centers.
    If the nodes in the primary data center are unavailable due to data center outage. Then how I can able to access node in the WSFC (Windows Server Failover Cluster) in the secondary disaster recovery data center automatically with some script.
    I want to write script that can be able to check primary data center by pinging some IP after every 5 or 10 minutes.
    If that IP is unable to respond then script can be able to Perform Forced Manual Failover of Availability Group (SQL Server) and WSFC (Windows Server Failover Cluster)
    Can you please guide me for script writing for automatic failover in case of primary datacenter outage?

    You are trying to implement manually what should be happening automatically in the cluster. If the primary SQL Server becomes unavailable in the data center, it should fail over to the secondary SQL Server automatically.  Is that not working?
    You also might want to run this configuration by some SQL experts.  I am not a SQL expert, but if you have both hosts in the data center in a cluster, there is no need for replication between those two nodes as they would be accessing
    the database from some form of shared storage.  Then it looks like you are trying to implement Always On to the DR site.  I'm not sure you can mix both types of failover in a single configuration.
    FYI, it would make more sense to establish a file share witness in your DR site instead of placing a third node in the data center for Node Majority quorum.
    . : | : . : | : . tim

  • Just upgraded to TB 31.4.0 and it is no longer asking for password, will not download new mail but does connect to POP server. I can send (it asks for p-word)

    Failure to download or allow sign in started with current upgrade.
    Despite inability to sign in, I have access to all settings and address book.
    I've "repaired" the inbox folder and checked the firewall settings. Connection to POP server is fast. Downloads for the last week or so (prior to upgrade) have been VERY slow...
    Likely the solution is "simple", but I'm very much NOT a "software tech" kinda guy.... If you can help, please use small words ; )

    ''Pupster [[#question-1041384|said]]''
    <blockquote>
    Failure to download or allow sign in started with current upgrade.
    Despite inability to sign in, I have access to all settings and address book.
    I've "repaired" the inbox folder and checked the firewall settings. Connection to POP server is fast. Downloads for the last week or so (prior to upgrade) have been VERY slow...
    Likely the solution is "simple", but I'm very much NOT a "software tech" kinda guy.... If you can help, please use small words ; )
    </blockquote>
    No idea why, but the problem seems to have resolved its self..

  • Mail stops talking to POP server and deletes inbox contents

    Mail has just started playing up: first by refusing to talk to (download from) my pop server (onetel) and then by deleting all the messages in my inbox. The connection doctor says everything is ok and even 'get info' will list messages on the pop server. Entourage also works fine too. However perhaps most annoyingly, many of the messages started saying The message from xxx concerning “yyy” has not been downloaded from the server. You need to take this account online in order to download it. I have tgried a number of things ( eg rebuild and synchronise) which have perhaps resulted in a load of stuff being deleted.
    Any suggestions as to what has happened and how to fix it? Any clues on how to retrieve the lost emails would be especially welcome!
    ibook 12" G4 1.33GHz   Mac OS X (10.4.9)   Mail 2.1

    In the Finder, open Home/Library/Mail and find your
    one or more POP account folders. Control-click on
    each such POP folder, and choose Get Info -- what
    size is reported? Open the POP folder, and find the
    INBOX.mbox folder -- open it and report the files and
    folder within, without listing the files in the
    Messages folder.
    Ernie
    Hi,
    the pop folder reports a sze of 868kb and the INBOX.mbox folder contains only an Info.plist file and a messages folder.
    As well as the messages in the inbox, all but one of those that were in the sent folder are also missing. Spotlighting for the missing e-mails turns up nothing either.
    I am most mystified that Mail appears to have deleted messages without warning and without putting them somewhere sensible like the Deleted messages folder or the Trash! Could it be happening if the synchronise button is hit?
    The POP connection problem is also a complete mystery - in fact it is currently working fine!

  • Workflow server end embedded PL/SQL and XDB

    Hi,
    I read in the Installation Guide that we must use Apache. We have Oracle 11.1.0.7 and embedded PL/SQL (from APEX) and don't use Apache. Is it possible to do so and install Workflow server without a HTTP-Server?
    Thank you for your help
    Siegwin

    The Workflow Server is NOT certified with oracle database version 11g. But yes if you are using DB 10gR2 then without HTTP server you can install Workflow Server and use that. Conceptually, it applies on 11g also but Workflow Server is no more released with Oracle 11g DB, so I can not comment whether you would be able install and use Workflow Server with 11g.

  • Guide to differences between SQL Server Transact SQL and Oracle PL/SQL

    Does anyone know of a good book (or online guide) that has an in-depth comparison of the differences between SQL Server Transact SQL and Oracle PL/SQL? (Something more than a beginner's guide)

    Hello,
    Below links will surely be helpful
    Discontinued features in SQL 2012
    Depricated features in SQL Server 2012
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

Maybe you are looking for