How can i create a socket connection through an http proxy

i'm trying to make a socket connection send an email - i have code that works when you don't have to go through a proxy server but i can't make it pass the proxy server.
import java.net.*;
import java.io.*;
import java.util.*;
public class Mail
public String to_address = "[email protected]";
public String from_address = "[email protected]";
public String sendSub = "HeHeHe";
public String sendBody = "hehehe - it worked";
// This is created to allow data to be read in by the keyboard.
BufferedReader in = new BufferedReader(
new InputStreamReader(System.in));
     private void Mail(String to_address, // recipient's addresses
String from_address, // sender's address
String sendSub, // subject
String sendBody) // Message
               throws IOException, ProtocolException,      UnknownHostException {
     Socket socket;                // creates a Socket named socket
     PrintStream out;               // stream to write to socket
     String host = "imap.btopenworld.com";          // identification of the mail server host
// creates a new socket for connection to the mail server
// as well as two variables for the read and write streams
     socket = new Socket(host, 25); // opens socket to host on port 25 (SMTP port)
     out = new PrintStream(socket.getOutputStream());
// read the initial message
     in.readLine();
// Dialog with the mail server
// send HELO to SMTP server HELO command is given by a connecting SMTP host
     out.println( "HELO " + host );
     out.flush() ;
     in.readLine();
// Once we are connected to the mail server we start sending the email...
// send "from"
     out.println( "MAIL FROM: " + from_address );
     out.flush() ;
     in.readLine();
// send "to"
     out.println( "RCPT TO: " + to_address );
     out.flush() ;
     in.readLine();
// prepare the mailserver to receive the data
     out.println( "DATA" );
     out.flush() ;
     in.readLine();
// Send actual email
     out.println("From: " + from_address);
     out.println("To: " + to_address);
     out.println( "Subject: " + sendSub + "\n" );
     out.flush() ;
     out.println("");
     out.println( sendBody ) ;
     out.println(".") ; // standard to determine end-of-body
     out.flush() ;
     in.readLine();
//Quit and closes socket
     out.println("QUIT");
     out.flush();
     in.close() ;
     socket.close() ;
     return ;
public static void main (String [] args) throws IOException
Mail themail = new Mail();
}

i've tried that but it doesn't seem to do nething - this is how i implemented it...
import java.net.*;
import java.io.*;
import java.util.*;
public class Mail
public String to_address = "[email protected]";
public String from_address = "[email protected]";
public String sendSub = "HeHeHe";
public String sendBody = "hehehe - it worked";
// This is created to allow data to be read in by the keyboard.
BufferedReader in = new BufferedReader(
new InputStreamReader(System.in));
     private void Mail(String to_address, // recipient's addresses
String from_address, // sender's address
String sendSub, // subject
String sendBody) // Message
               throws IOException, ProtocolException,      UnknownHostException {
     Socket socket;                // creates a Socket named socket
     PrintStream out;               // stream to write to socket
     String host = "imap.btopenworld.com";          // identification of the mail server host
// creates a new socket for connection to the mail server
// as well as two variables for the read and write streams
     socket = new Socket(host, 25); // opens socket to host on port 25 (SMTP port)
     out = new PrintStream(socket.getOutputStream());
// read the initial message
     in.readLine();
System.getProperties().put( "proxySet", "true" );
          System.getProperties().put( "proxyHost", "144.124.16.28" );
          System.getProperties().put( "proxyPort", "8080" );
// Dialog with the mail server
// send HELO to SMTP server HELO command is given by a connecting SMTP host
     out.println( "HELO " + host );
     out.flush() ;
     in.readLine();
// Once we are connected to the mail server we start sending the email...
// send "from"
     out.println( "MAIL FROM: " + from_address );
     out.flush() ;
     in.readLine();
// send "to"
     out.println( "RCPT TO: " + to_address );
     out.flush() ;
     in.readLine();
// prepare the mailserver to receive the data
     out.println( "DATA" );
     out.flush() ;
     in.readLine();
// Send actual email
     out.println("From: " + from_address);
     out.println("To: " + to_address);
     out.println( "Subject: " + sendSub + "\n" );
     out.flush() ;
     out.println("");
     out.println( sendBody ) ;
     out.println(".") ; // standard to determine end-of-body
     out.flush() ;
     in.readLine();
//Quit and closes socket
     out.println("QUIT");
     out.flush();
     in.close() ;
     socket.close() ;
     return ;
public static void main (String [] args) throws IOException
Mail themail = new Mail();
}

Similar Messages

  • How can I create a database connection to Cloudscape database in 9iJDeveloper?

    How can I create a database connection to Cloudscape database in
    9iJDeveloper?
    thanks.

    Hi,
    I assume you have a JDBC driver for Cloudscape.
    1. In the IDE System Navigator, expand the Connections Node.
    2. Right-click on the Database Connection and choose New
    Connection .. .
    3. Click pass the welcome screen.
    4. In Step 1, name your connection and choose "3rd party JDBC
    Driver"
    5. Follow the rest of the steps and provide username/password,
    class name and URL, test and you should be ready to go.
    Good luck.

  • How can I create a live hyperlink through PPT / PDF?

    1. I create a PPT with a "live" hyperlink - www.apple.com
    2. I test the hyperlink in PPT - no issues.
    3. I save the PPT as a PDF.
    4. I email the PDF to myself.
    5. The hyperlink is now dead.
    6. How do I create a "live hyperlink", through PDF, that I can access via my iPAD?
    THANK YOU!!!

    If you're talking about LIVE video (as in, people can see what you're doing RIGHT NOW), you can't host that on Youtube (yet), although there are applications (not part of iLife, though) to let you stream to a personal website. If you just want to record yourself, then upload it, sure, you can do so using iMovie 11.
    This page explains iMovie's iSight import feature - provided your webcam is supported, the same should work for you.
    Matt

  • How can I create a data connection without ODBC (directly with OLE DB)

    If connecting to an OLE DB data source, which is not defined as ODBC, the well known error message appears in Acrobat, that the environment is not trusted. The Designer Help says, that the document must be certified in Acrobat to run OLE DB without ODBC. So I certified the document in Acrobat allowing dynamic content for it. But the error message always appears. So I have some questions to this:
    How is the correct certification process in Acrobat to define a trusted environment for using OLE DB without ODBC?
    Why generates using of ODBC an trusted environment? With using ODBC data sources can be changed external from Acrobat, so I must think, ODBC is absolutely insecure.
    Why is OLE DB without ODBC insecure? Here I have a defined connection string, which cannot be changed at runtime (if the form developer this doesn't want).
    And why is the first record displayed instead of the error message, if using OLE DB without ODBC, but navigation is impossible?
    This seems all very mysterious to me.
    Does anyone in the world has ever created an OLE DB data connection (without ODBC) with Designer and Acrobat, which runs in a trusted environment?
    Thanks for your answers.
    Michael

    For the Projects, the trick will be the Asset files. If they will fit onto DVD DL discs, you're OK. If they are too large (DV-AVI is ~ 13GB per hour), then you'll need some type of backup, or spanning software, that will write files across multiple discs. A better choice, IMO, would be a 1 - 2 TB external, where you can use Project Manager, or just Windows Explorer and Copy, to do the entire Project folder with Assets. I'd recommend against a USB and go at least for FW-400. FW-800 would be better, but you'll need FW-800 connections on your computer. eSATA would be the best, but then you'll need eSATA connectors.
    Good luck,
    Hunt

  • TS2756 How can i create a new usb connection (service)  on my iMac for sharing internet from my iPhone5 ( i seem have to deleted it )

    How can i create a new usb connection (service)  on my iMac for sharing internet from my iPhone5 ( i seem have to deleted it )
    i know its not a problem whit my carrier o data plan or sharing preferences on the ipone because when i use it un my laptop it works perfectly through
    the usb and even works on the Imac through wifi and bluethood tethering but NOT through usb!!.
    the problem is that trying to make it work i deleted the "profile" usb iphone on the network prefereces panel. Now i only have 3 options: ethernet / wifi / bluetooth
    but not the usb iPhone i used to have.
    And when i try to add a new one i dont get a USB option.
    can some one help me please??
    this is how it looks (after the bluetooth PAN i used to have USB iPhone option)

    The question would be more appropriate in the Mac forums as it is not really related to the iPhone.

  • How can I display modes in connection create window

    Hi Pro,
         I create a environment/model, then I get into EPM excel addin, try to create a connection, but eventhough I choose my environment created, but I get blank list for model drop down list. how can I display modes in connection create window?

    Hi Yi Fei,
    Add user to your environment, check their security profiles, also check roles in BW.
    Andy

  • How can I print from my iPad through my Mac Book Pro which is connected to a printer?  I was told I could do this.

    How can I print from my iPad through my Mac Book Pro which is connected to a printer?  I was told I could do this when the iPad and Mac Book Pro are synched together.

    Antique lady wrote:
    So If I download Printopia on my Mac Book Pro, do I go to iTunes to somehow connect the computer and the iPad? 
    No.
    Printopia (running on your Mac) connects the iPad to your printer.

  • How can I create a new Numbers Document through AppleScript?

    How can I create a new Numbers Document through AppleScript?
    I try this:
    tell application "Numbers"
    make new document with properties {template name:"blank"}
    end tell
    But don't work.
    Where can I find documentation about it?
    Thanks

    If you try to invent your own syntax, you are starting on very wrong basis.
    The required syntax is defined by the Numbers AppleScript's dictionary.
    This one doesn't know what is a template.
    This is why, in the link posted by badunit, I use an other scheme to create a new document.
    I know that it's awful but it's the only one available at this time.
    Yvan KOENIG (VALLAURIS, France) samedi 4 juin 2011 11:25:25
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.7
    Please : Search for questions similar to your own before submitting them to the community
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !

  • How can I create a new folder in an external disk that is connected via USB to my Mac?

    How can I create a new folder in an external disk that is connected via USB to my Mac?

    Just like you would create a new folder anywhere. Open the drive's icon from your desktop or the Finder, and click shift-command-N. (Or use the Finder menu if you prefer - File - New Folder).
    If you can't create a folder, your drive may be the wrong format (you can't write to a Windows/NTFS formatted drive, for example). You'll have to back up any files you have on there, and then use Disk Utility to reformat it to Mac Extended (if it will only be used on a Mac) or MS-DOS format (if you want to share it with a PC).
    Matt

  • How can you create a playlist with music and music video and play those from same playlist through Apple TV?

    How can you create a playlist on Ipod touch with music and music video,  and play those from same playlist through Apple TV?  I can download, create a playlist with both music and music video, stream that through the Apple TV with no problem.  The sound and the information show up on the TV, but when it gets to a music video, it only shows the information and "artwork".
    I also have a video playlist - videos play fine through the Apple TV, but will not shuffle through all videos - continues to repeat the same one.  I have most definitely selected shuffle in both locations - from the playlist and on the ipod video screen while video is playing.

    I finally got it... had to sync the photos with the music in iMovie, arrange the voiceover in GarageBand then export to iTunes, and then I was able to put it all together in iMovie and burn in iDVD... had a few glitches along the way but finally finished : )
    Message was edited by: jpewald

  • How many statements can be created with one connection?

    how many statements can be created with one connection?

    and on available memory. At some point, even were the database to allow an infinite number, you'd run out of memory.

  • Hi folks, you might know how to fix this: my wifi shows (no hardware installed) then I went to system preferences and deleted the wifi connection, I went also to system information and I can not see wifi listed on Network, how can I create a new wifi ?

    Hi folks, you might know how to fix this: my wifi shows (no hardware installed) then I went to system preferences and deleted the wifi connection, I went also to system information and I can not see wifi listed on Network, how can I create a new wifi or simply solve this, I have tryied shotdown pressing keys like P and R, option, etc. Please help me .

    Please read this whole message before doing anything.
    This procedure is a diagnostic test. It’s unlikely to solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
    The purpose of the test is to determine whether the problem is caused by third-party software that loads automatically at startup or login, by a peripheral device, by a font conflict, or by corruption of the file system or of certain system caches.
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards, if applicable. Start up in safe mode and log in to the account with the problem. You must hold down the shift key twice: once when you turn on the computer, and again when you log in.
    Note: If FileVault is enabled, or if a firmware password is set, or if the startup volume is a Fusion Drive or a software RAID, you can’t do this. Ask for further instructions.
    Safe mode is much slower to start up and run than normal, with limited graphics performance, and some things won’t work at all, including sound output on certain models. The next normal startup may also be somewhat slow.
    The login screen appears even if you usually login automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    Test while in safe mode. Same problem?
    After testing, restart as usual (not in safe mode) and verify that you still have the problem. Post the results of the test.

  • How can I create a simple chat function in a mobile app for iOS and Android

    I am wondering how can I create a chat function in my mobile app creating in AIR and Flex. The chat should be similar to the one in WhatsApp.
    Do you know some possible solutions?
    Thank you in advance!

    To enable chat messages, you need a server. The kind of server depends on the application. Do you want to create a chat like application like WhatsApp, where the server pushes messages without an active connection? Or do you have some sort of online game, where chat messages can only be transferred when the client is connected already?
    I have an online game where clients are connected to a Java server at all time. From there it is pretty straight forward:
    2 textfields:
    - 1 line textfield for input messages
    - multi-line textfield for chat history. Make sure the textfields autoscrolls to the bottom when the content changes
    on enter or button push, send a socket message to the server.
    the server broadcasts all messages to all clients that are subscribers of the chat group.

  • How can i test my vpn connection?

    so recently i decided to test if ver 1.3.0.3 of the quickvpn client would work better with the 1.3.0.5 rvs4000 firmware. i loaded quickvpn to an xp pro computer (freshly built, i might add) and got to work. in order to test the connection, i attempted to piggy back off an unsecured wireless network. this network is on the same ISP network as i am.
    i use dynamic DNS, and the unsecured wireless network could resolve my IP correctly, but for some reason i couldnt connect to my home network from the unsecured network. my router is set to respond to lan requests, but i couldnt ping it. my router passes HTTP traffic to a computer in my network, but i couldnt bring up the webpage. finally, my router responds with the router config page over port 443, and i couldnt bring that up.
    so i used my ISP's dialup service to test. initially, as always, i had a million problems with the vpn client. systematically, i tried to resolve the issues. i installed the patch in the readme for quickvpn. i checked log files to see where stuff was failing. eventually, i could connect to the VPN, but would get that "remote gateway is not responding" crap. i know of a (poor) workaround for this which allows you to "finalize" the connection, but that workaround doesnt allow you to ping around in your network. sometime later, after randomly messing with settings, the tunnel would connect without the workaround. i have no idea what "fixed" this.
    despite all this, my 28.8Kbps connection wouldnt allow me to do anything meaningful on my network. i couldnt connect to the router or to a server of mine (http or fileshare). the only thing i could do was ping internal devices. other requests seemed to "hang" rather than timeout or do anything more concrete. basically, i gave up on testing using dialup, even though my router and the client software confirm a good connection. but i still wasnt convinced.
    next, i figured i could create some type of "DMZ" on my network by placing a switch between my ISP's modem and my router. im not a cisco network professional by any means, but im pretty familiar with networking on a above-average level. that said, despite my best, i couldnt get my quickvpn computer to see my router from the "DMZ".
    finally, i figured i could just test the tunnel while directly connected to my network's lan. bad idea. everything seems to go okay until it locks up on "activating policy". rebooting or otherwise ending the negotiation ends in the computer being unable to do anything anymore. when i try to ping anything, i get "negotiating ip security" ad infinitum. the only way i could fix this was by doing a system restore.
    so here's the question: how can i test my quickvpn connection?why can't i just tunnel through my network? and before you scream that you can't, thegreenbow vpn client has NO PROBLEM connecting to my rvs4000 while connected to my own network.

    Hi Aaron,
    I am going exactly the same thing as you however, I had my cousin buy and install a RVS4000 at his house in Australia.
    I access it from the USA so that I can help manage his Local Area Network, he is just not technical..
    I setup a DDNS client on his RVS4000 so that I can always get to his Router via a domain name rather than a IP address.
    I noticed that you didn't mention anything regarding importing client certificate into the directory of the VPN client on your PC.
    I also noticed I disabled IPSec passthrough on the router in Australia, see the pictures below, not sure why, but the VPN client is working.
    I also did not setup any gateway to gateway VPN tunnels, Only added a client , exported certificate as per the manual, See the last screen capture below.
    You will also note if you view the screen captures that my cousins RVS4000 has not been upgraded to the new code.Is there a reason for that...not really...he's just a user, not really technical.  Also note I have not added any VPN tunnels on my RVS4000.
    I have a reasonably reliable connection between the USA and Australia. I didn;t have to play with any other options, just add users to the VPN client database.
    Your description of the working environment of your PC is missing details on the version of XP, so i will mention the following taken from the software release notes of the RVS4000 ;
    There is a known issue with Windows XP SP2 Firewall.
    ICMP packets are always dropped by the firewall when the firewall is enabled.
    This issue causes the QuickVPN client to be unable to establish a tunnel with the remote QuickVPN server successfully.
    Microsoft has released a patch to fix this issue, which you can get from:
    http://support.microsoft.com/kb/889527/en-us
    After you install the patch, the issue should be resolved. You can also fix this issue by upgrading Windows XP to SP3.
    You cannot plug a PC on the same network as the router for testing, they must be on dissimilar WAN  networks for testing purposes.
    Your remote  PC VPN client will not be allocated a IP address in the RVS4000's network, hosts behind the RVS4000 will still respond to pings, as they direct the responses to their default gateway, the RVS4000.
    The thegreenbow VPN client is a distracter at this point costing 50 something EURO  for a license, lets try to get the quickVPN client working !
    So, if you still wish try the following, firstly make sure your XP has been upgraded to  SP3;
    1.  If you upgraded your router to the new version of code, then reset your router to factory defaults to re-initialize your router, yes start again.
    2.  Export the VPN client certificate to the directory that contains the VPN client.  In my case it is;
               "C:\Program Files\Cisco Small Business\QuickVPN Client"
    3.  add a VPN client account to the router
    4.  Use port 60443 from the quickVPN client. and try  VPNing to the router.
    5  hmmm, if the client still fails try disabling IPSec Passthrough on the router for grins and giggles.
    If this fails, call the SBSC at the following location for resolution;
    http://www.cisco.com/en/US/support/tsd_cisco_small_business_support_center_contacts.html
    good luck ...regards Dave

  • How can I get authentication and authorization through OS X open directory with the Sun ZFS STOR ZS3-2

    how can I get authentication and authorization through OS X open directory with the Sun ZFS STOR ZS3-2
    I have configure NFS, I need help configuring the share that I created in the Sun ZFS STOR ZS3-2 to connect with the OS X Open Directory

    Hi,
        You may  try checking the help page for ldap configuration :
    https://<Appliance_IP>:215/wiki/index.php/Configuration:Services:LDAP
    ZFS Storage supports LDAP, NIS, AD as directory service.
    Hope Open Directory is also based on LDAP and may work in similar fashion.
    Thanks
    Nitin

Maybe you are looking for