Re: send SMTP email using socket problem: java.net.ConnectException
From: Steve Horsley (shoot_at_the.moon)
Date: 02/21/05
- Next message: Bjorn Abelli: "Re: Question on Syntax differences between application and applet"
- Previous message: Ken Applequist: "Question on Syntax differences between application and applet"
- In reply to: jrefactors_at_hotmail.com: "send SMTP email using socket problem: java.net.ConnectException"
- Next in thread: Daniel Tahin: "Re: send SMTP email using socket problem: java.net.ConnectException"
- Reply: Daniel Tahin: "Re: send SMTP email using socket problem: java.net.ConnectException"
- Reply: Steve Sobol: "Re: send SMTP email using socket problem: java.net.ConnectException"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 21 Feb 2005 18:18:09 +0000
jrefactors@hotmail.com wrote:
> I want to write the socket program to send SMTP email, without using
> any JavaMail API.
> Here's the program, but it turns out it has the following exceptions: I
> don't know
> which part it went wrong. please advise. thanks!!
>
> /**
> java.net.ConnectException: Connection timed out: connect
> at java.net.PlainSocketImpl.socketConnect(Native Method)
> at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
> at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
> at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
> at java.net.Socket.connect(Socket.java:452)
> at java.net.Socket.connect(Socket.java:402)
> at java.net.Socket.<init>(Socket.java:309)
> at java.net.Socket.<init>(Socket.java:124)
> at SMTPTest.sendMail(SMTPTest.java:20)
> at SMTPTest.main(SMTPTest.java:12)
> */
>
> ======================================================================
> import java.net.*;
> import java.io.*;
> import java.util.*;
>
> /**
> * send SMTP email using socket
> *
> */
> public class SMTPTest
> { public static void main(String[] args)
> { SMTPTest smtp = new SMTPTest();
> smtp.sendMail();
> }
>
> public void sendMail()
> {
> try
> {
> Socket s = new Socket("smtp.gmail.com", 465); //smtp.gmail.com, 465
I don't think gmail allow you to send mail messages through their server using
SMTP at all. They allow POP3 to retrieve messages though.
You can prove by hand that they don't accept SMTP with this command:
telnet smtp.google.com 465
Steve
- Next message: Bjorn Abelli: "Re: Question on Syntax differences between application and applet"
- Previous message: Ken Applequist: "Question on Syntax differences between application and applet"
- In reply to: jrefactors_at_hotmail.com: "send SMTP email using socket problem: java.net.ConnectException"
- Next in thread: Daniel Tahin: "Re: send SMTP email using socket problem: java.net.ConnectException"
- Reply: Daniel Tahin: "Re: send SMTP email using socket problem: java.net.ConnectException"
- Reply: Steve Sobol: "Re: send SMTP email using socket problem: java.net.ConnectException"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|