home *** CD-ROM | disk | FTP | other *** search
- package com.zerog.ia.download.utility;
-
- import java.io.DataInputStream;
- import java.io.DataOutputStream;
- import java.io.IOException;
- import java.net.Socket;
- import java.net.UnknownHostException;
-
- public class Mail extends Thread {
- String smtpServer;
- String myName;
- String fromAddress;
- String toAddress;
- String message;
- Socket socketSmtpServer = null;
- DataOutputStream dos = null;
- DataInputStream dis = null;
- boolean mailSent;
- long timeoutSeconds = 8L;
-
- public Mail(String var1, String var2, String var3, String var4, String var5) {
- this.smtpServer = var1;
- this.myName = var2;
- this.fromAddress = var3;
- this.toAddress = var4;
- this.message = var5;
- ((Thread)this).setPriority(1);
- }
-
- public boolean sendMail() {
- this.mailSent = false;
- ((Thread)this).start();
- long var1 = System.currentTimeMillis();
-
- while(!this.mailSent && System.currentTimeMillis() - var1 < this.timeoutSeconds * 1000L) {
- try {
- Thread.sleep(500L);
- } catch (Exception var4) {
- }
- }
-
- return this.mailSent;
- }
-
- public void run() {
- try {
- this.makeConnection();
- } catch (Exception var2) {
- this.mailSent = false;
- }
-
- }
-
- void makeConnection() throws Exception {
- try {
- this.socketSmtpServer = new Socket(this.smtpServer, 25);
- this.dos = new DataOutputStream(this.socketSmtpServer.getOutputStream());
- this.dis = new DataInputStream(this.socketSmtpServer.getInputStream());
- } catch (UnknownHostException var4) {
- throw var4;
- } catch (IOException var5) {
- throw var5;
- }
-
- String var1 = this.dis.readLine();
- this.dos.writeBytes("HELO " + this.myName + "\n");
- var1 = this.dis.readLine();
- this.dos.writeBytes("RSET\n");
- var1 = this.dis.readLine();
- this.dos.writeBytes("MAIL FROM:<" + this.fromAddress + ">\n");
- this.dis.readLine();
- this.dos.writeBytes("RCPT TO:<" + this.toAddress + ">\n");
- this.dis.readLine();
- this.dos.writeBytes("DATA\n");
- var1 = this.dis.readLine();
- this.dos.writeBytes("To: " + this.toAddress + "\n");
- this.dos.writeBytes("From: " + this.fromAddress + "\n");
- this.dos.writeBytes("Subject: InstallAnywhere Web Install Problem\n");
- String var2 = "SimpleBoundary";
- this.dos.writeBytes("Mime-Version 1.0\n");
- this.dos.writeBytes("Content-Type: text/plain; charset=\"us-ascii\"\n\n");
- this.dos.writeBytes(this.message);
- this.dos.writeBytes("\n.\n");
- var1 = this.dis.readLine();
- this.dos.writeBytes("QUIT\n");
- var1 = this.dis.readLine();
- this.dos.close();
- this.dis.close();
- this.socketSmtpServer.close();
- this.mailSent = true;
- }
- }
-