File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes sending emails Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "sending emails" Watch "sending emails" New topic

sending emails

Sankar Subbiramaniam
Ranch Hand

Joined: Oct 03, 2000
Posts: 116
Hello All,
In my application, after generating user and password, i need to send the details thru e-mail to concerned person. So, i did this via socket programming and following SMTP protocol.
After sending the header information, i receive from the SMTPserver a response code of 220 (indicating it is ready to receive data.) Then i send the message body, after which i get a response code of 250 (indicating success). But when i checked my mailbox i couldnot see the received mails. It is getting lost somewhere.
Please help. I was sending the mails using webappcabaret SMTP and the receiving server was and
FYI.. i am giving the exact responses received:
<b>response after header sent</b> : 220 db1 ESMTP Sendmail 8.9.3/8.9.3; Mon, 2 Oct 2000 21:24:57 -0700
<b>response from server after data is received:</b> 250 db1 Hello [], pleased to meet you
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
While manually implementing the SMTP protocol is an interesting learning exercise, most people use one of the many available (free) mail classes which do it already. Sun's Java Mail API is the official way to do this, but there are plenty of alternatives. If you search for JavaMail here at the Saloon you will find lots of example code and installation instructions for Java Mail.
[This message has been edited by Frank Carver (edited October 03, 2000).]

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Sankar Subbiramaniam
Ranch Hand

Joined: Oct 03, 2000
Posts: 116
Thanks Frank. But i am interested in writing using sockets, as it will give me a better understanding of mail transfer protocols.
Also i have seen code using Is it part of standard JDK ? where can i find the documentation ?
Frank Carver

Joined: Jan 07, 1999
Posts: 6920 is available but undocumented in most Sun JDKs. I would strongly caution against using it, though. Although it makes some simple cases simpler, it hasn't got the flexibility of JavaMail. Worst of all, it is not supported, and you can't guarantee that it will be present. If you get stuck with your implementation of the protocol, thge best place to look is in the public java source code repositories. There arev plenty of SMTP implementations available with source code for you to look at.
I agree. Here's the link:
subject: sending emails
Similar Threads
Problem with sending mails
the mails are goes to Badmail folder of the host
java mail error SendFailedException
Sending mail with authentication to Exchange Server 2007
530 5.7.1 Client was not authenticated