SMTP java program...
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I wrote the below code as a homework exercise. I am to create a Java program that interacts with an SMTP server to send e-mail messages. I've gotten it to work, up to the RCPT TO: <[email protected]> portion. The program will parrot the command to me, but I can't get the server to respond; it does not print the 'destination OK' message on the console, as it should (the String response = br.readline(), then System.out.println(response) should parrot back the server response). Can anyone point me in the right direction? I'm almost there, just have to get past this sticking point. Thanks in advance!
-Patrick
[ January 31, 2008: Message edited by: Patrick Brooks ]
Hello. My name is Inigo Montoya. You killed my father. Prepare to die.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
For more information, see: Don't println to a socket
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hello. My name is Inigo Montoya. You killed my father. Prepare to die.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Originally posted by Patrick Brooks:
[QB]Hi Joe. I tried using /r/n on all of the commands (forgot to put it in all of them), but with the same result... the program works fine up to the rcpt to: point, then deadlocks.
So you are actually getting a response from HELO and FROM? I should read more carefully.
Check your HELO command.
There's also a line where you print one thing to the screen, but send something else to the socket. That can't be good!
Originally posted by Patrick Brooks:
[QB]
I'm using 'write' instead of 'println', though, just thought I'd point that out, since the article spoke of 'println'.
The problem is reversed in your case. You problem is reading from a socket and the example is given as if the problem were with writing. The same principal applies. Both BufferedReader and PrintWriter are poor choices for cross-platform communication because the use platform-specific EOL characters.
[ January 30, 2008: Message edited by: Joe Ess ]
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Originally posted by Joe Ess:
The problem is reversed in your case. You problem is reading from a socket and the example is given as if the problem were with writing. The same principal applies. Both BufferedReader and PrintWriter are poor choices for cross-platform communication because the use platform-specific EOL characters.
[ January 30, 2008: Message edited by: Joe Ess ]
Hmmm, OK, what is a good substitute for BufferedReader, then? Sorry, I'm new to network programming. I caught the HELO error and the command error you pointed out, thanks, but still having the same problem.
Hello. My name is Inigo Montoya. You killed my father. Prepare to die.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Originally posted by Ulf Dittmer:
I think you can still use BufferedReader, just not its readLine method. Of course, handling complete lines is one of the main attraction of Readers, so you may want to work with InputStream directly instead.
So, do you think that the BufferedReader is what is causing my problem? Strange that it works fine for the 'mail from' portion, but not for the 'rcpt to' portion. I tried with /r/n, with /n, and with just /r, but to no avail. Thanks!
-Patrick
Hello. My name is Inigo Montoya. You killed my father. Prepare to die.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Originally posted by Patrick Brooks:
So, do you think that the BufferedReader is what is causing my problem?
No. I'll say it again:
Check your HELO command.
There's also a line where you print one thing to the screen, but send something else to the socket. That can't be good!
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hello. My name is Inigo Montoya. You killed my father. Prepare to die.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Just a nitpick, deadlock refers to a specific situation, usually between two or more threads or processes. I/O blocks.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Originally posted by Joe Ess:
Your code above with the changes I stated worked for me. Let's see your current code.
Just a nitpick, deadlock refers to a specific situation, usually between two or more threads or processes. I/O blocks.
Oops, I forgot to post it... here it is:
Hello. My name is Inigo Montoya. You killed my father. Prepare to die.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
[ January 31, 2008: Message edited by: Joe Ess ]
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-Patrick
Hello. My name is Inigo Montoya. You killed my father. Prepare to die.
| Liar, liar, pants on fire! refreshing plug: Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |








