Send the SMTP DATA command in preparation to send an email message. This method returns a DotTerminatedMessageWriter instance to which the message can be written. Null is returned if the DATA command fails.
You must not issue any commands to the SMTP server (i.e., call any (other methods) until you finish writing to the returned Writer instance and close it. The SMTP protocol uses the same stream for issuing commands as it does for returning results. Therefore the returned Writer actually writes directly to the SMTP connection. After you close the writer, you can execute new commands. If you do not follow these requirements your program will not work properly.
You can use the provided {@link org.apache.commons.net.smtp.SimpleSMTPHeader}class to construct a bare minimum header. To construct more complicated headers you should refer to RFC 822. When the Java Mail API is finalized, you will be able to use it to compose fully compliant Internet text messages. The DotTerminatedMessageWriter takes care of doubling line-leading dots and ending the message with a single dot upon closing, so all you have to worry about is writing the header and the message.
Upon closing the returned Writer, you need to call {@link #completePendingCommand completePendingCommand() }to finalize the transaction and verify its success or failure from the server reply.
@return A DotTerminatedMessageWriter to which the message (includingheader) can be written. Returns null if the command fails.
@exception SMTPConnectionClosedException If the SMTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send SMTP reply code 421. This exception may be caught either as an IOException or independently as itself.
@exception IOException If an I/O error occurs while either sending acommand to the server or receiving a reply from the server.