Class 2 |
Intermediate Java 30-IT-397 |
|
Send an e-mail
-
Generating an e-mail is an incredibly easy thing to do, and we can do it
with the knowledge we already have.
-
Spoofing a From address is also very easy. Unfortunately,
this has lead to a lock down on many servers, so that you can't just connect
and send an e-mail from anyone.
-
In the old days, you could just dummy up an e-mail to anyone on any server.
Not so now. As a matter of fact, I am writing and testing this from
home with the expectation that it will not work on oz. In class,
we'll try it from oz and we'll jus see if it works. I am going to
try it on one.net and zoomtown, my ISP at home. Unfortuantely, at
this time Zoomtown is down and I can't test it. :(
-
Now, the details of sending an e-mail:
-
E-mails are sent on port 25. Connect to the server as you normally
would, just specify 25. This is considered the SMTP, or Simple Mail
Transport Protocol, port.
-
Most Unix servers use sendmail for SMTP. If you've ever written a
Perl script that sends an e-mail, it probably uses sendmail. The
e-mails we generated in 30-IT-252 used sendmail on oz.
-
After you've opened a socket, send you need to send data to sendmail.
Here's an example of me sending an e-mail to myself:
HELO
MAIL FROM: <jonesbr@email.uc.edu>
RCPT TO: <UCInternet2@yahoo.com>
DATA
Hello, I am sending this from Java.
See you later,
Brandan
QUIT
-
We'll write a program similar to the one on page 211 in the book, including
the threads.
Example

Created by: Brandan Jones
December 17, 2001