diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SendEmail.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SendEmail.java deleted file mode 100644 index c73f5bd89..000000000 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SendEmail.java +++ /dev/null @@ -1,409 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.StringTokenizer; -import org.apache.myrmidon.api.TaskException; -import org.apache.tools.ant.Task; -import org.apache.tools.mail.MailMessage; - -/** - * A task to send SMTP email.
- *
- *
- *
- *
- *
- *
- * @author glenn_twiggs@bmc.com
- * @author Magesh Umasankar
- */
-public class SendEmail extends Task
-{
- private String mailhost = "localhost";
- private int mailport = MailMessage.DEFAULT_PORT;
- private ArrayList files = new ArrayList();
- /**
- * failure flag
- */
- private boolean failOnError = true;
- private String from;
- private boolean includefilenames;
- private String message;
- private String subject;
- private String toList;
-
- /**
- * Creates new SendEmail
- */
- public SendEmail()
- {
- }
-
- /**
- * Sets the FailOnError attribute of the MimeMail object
- *
- * @param failOnError The new FailOnError value
- * @since 1.5
- */
- public void setFailOnError( boolean failOnError )
- {
- this.failOnError = failOnError;
- }
-
- /**
- * Sets the file parameter of this build task.
- *
- * @param filenames Filenames to include as the message body of this email.
- */
- public void setFiles( String filenames )
- throws TaskException
- {
- StringTokenizer t = new StringTokenizer( filenames, ", " );
-
- while( t.hasMoreTokens() )
- {
- files.add( resolveFile( t.nextToken() ) );
- }
- }
-
- /**
- * Sets the from parameter of this build task.
- *
- * @param from Email address of sender.
- */
- public void setFrom( String from )
- {
- this.from = from;
- }
-
- /**
- * Sets Includefilenames attribute
- *
- * @param includefilenames Set to true if file names are to be included.
- * @since 1.5
- */
- public void setIncludefilenames( boolean includefilenames )
- {
- this.includefilenames = includefilenames;
- }
-
- /**
- * Sets the mailhost parameter of this build task.
- *
- * @param mailhost Mail host name.
- */
- public void setMailhost( String mailhost )
- {
- this.mailhost = mailhost;
- }
-
- /**
- * Sets the mailport parameter of this build task.
- *
- * @param value mail port name.
- */
- public void setMailport( Integer value )
- {
- this.mailport = value.intValue();
- }
-
- /**
- * Sets the message parameter of this build task.
- *
- * @param message Message body of this email.
- */
- public void setMessage( String message )
- {
- this.message = message;
- }
-
- /**
- * Sets the subject parameter of this build task.
- *
- * @param subject Subject of this email.
- */
- public void setSubject( String subject )
- {
- this.subject = subject;
- }
-
- /**
- * Sets the toList parameter of this build task.
- *
- * @param toList Comma-separated list of email recipient addreses.
- */
- public void setToList( String toList )
- {
- this.toList = toList;
- }
-
- /**
- * Executes this build task.
- *
- * @throws TaskException if there is an error during task execution.
- */
- public void execute()
- throws TaskException
- {
- try
- {
- MailMessage mailMessage = new MailMessage( mailhost );
- mailMessage.setPort( mailport );
-
- if( from != null )
- {
- mailMessage.from( from );
- }
- else
- {
- throw new TaskException( "Attribute \"from\" is required." );
- }
-
- if( toList != null )
- {
- StringTokenizer t = new StringTokenizer( toList, ", ", false );
-
- while( t.hasMoreTokens() )
- {
- mailMessage.to( t.nextToken() );
- }
- }
- else
- {
- throw new TaskException( "Attribute \"toList\" is required." );
- }
-
- if( subject != null )
- {
- mailMessage.setSubject( subject );
- }
-
- if( !files.isEmpty() )
- {
- PrintStream out = mailMessage.getPrintStream();
-
- for( Iterator e = files.iterator(); e.hasNext(); )
- {
- File file = (File)e.next();
-
- if( file.exists() && file.canRead() )
- {
- int bufsize = 1024;
- int length;
- byte[] buf = new byte[ bufsize ];
- if( includefilenames )
- {
- String filename = file.getName();
- int filenamelength = filename.length();
- out.println( filename );
- for( int star = 0; star < filenamelength; star++ )
- {
- out.print( '=' );
- }
- out.println();
- }
- BufferedInputStream in = null;
- try
- {
- in = new BufferedInputStream(
- new FileInputStream( file ), bufsize );
- while( ( length = in.read( buf, 0, bufsize ) ) != -1 )
- {
- out.write( buf, 0, length );
- }
- if( includefilenames )
- {
- out.println();
- }
- }
- finally
- {
- if( in != null )
- {
- try
- {
- in.close();
- }
- catch( IOException ioe )
- {
- }
- }
- }
-
- }
- else
- {
- throw new TaskException( "File \"" + file.getName()
- + "\" does not exist or is not readable." );
- }
- }
- }
- else if( message != null )
- {
- PrintStream out = mailMessage.getPrintStream();
- out.print( message );
- }
- else
- {
- throw new TaskException( "Attribute \"file\" or \"message\" is required." );
- }
-
- getLogger().info( "Sending email" );
- mailMessage.sendAndClose();
- }
- catch( IOException ioe )
- {
- String err = "IO error sending mail " + ioe.toString();
- if( failOnError )
- {
- throw new TaskException( err, ioe );
- }
- else
- {
- getLogger().error( err );
- }
- }
- }
-
-}
diff --git a/proposal/myrmidon/src/main/org/apache/tools/mail/MailMessage.java b/proposal/myrmidon/src/main/org/apache/tools/mail/MailMessage.java
deleted file mode 100644
index 228811992..000000000
--- a/proposal/myrmidon/src/main/org/apache/tools/mail/MailMessage.java
+++ /dev/null
@@ -1,535 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
- */
-package org.apache.tools.mail;
-
-import java.io.BufferedOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Iterator;
-
-/**
- * A class to help send SMTP email. This class is an improvement on the
- * sun.net.smtp.SmtpClient class found in the JDK. This version has extra
- * functionality, and can be used with JVMs that did not extend from the JDK.
- * It's not as robust as the JavaMail Standard Extension classes, but it's
- * easier to use and easier to install, and has an Open Source license.
- *
- * It can be used like this:
- *
- * Be sure to set the from address, then set the recepient addresses, then set
- * the subject and other headers, then get the PrintStream, then write the
- * message, and finally send and close. The class does minimal error checking
- * internally; it counts on the mail host to complain if there's any
- * malformatted input or out of order execution.
- *
- * An attachment mechanism based on RFC 1521 could be implemented on top of this
- * class. In the meanwhile, JavaMail is the best solution for sending email with
- * attachments.
- *
- * Still to do:
- *
- *
- * The same rules used here would apply to FTP and other Telnet based protocols
- * as well.
- *
- *
- *
- *
- *
- *
- * @author glenn_twiggs@bmc.com
- * @author Magesh Umasankar
- */
-public class SendEmail extends Task
-{
- private String mailhost = "localhost";
- private int mailport = MailMessage.DEFAULT_PORT;
- private ArrayList files = new ArrayList();
- /**
- * failure flag
- */
- private boolean failOnError = true;
- private String from;
- private boolean includefilenames;
- private String message;
- private String subject;
- private String toList;
-
- /**
- * Creates new SendEmail
- */
- public SendEmail()
- {
- }
-
- /**
- * Sets the FailOnError attribute of the MimeMail object
- *
- * @param failOnError The new FailOnError value
- * @since 1.5
- */
- public void setFailOnError( boolean failOnError )
- {
- this.failOnError = failOnError;
- }
-
- /**
- * Sets the file parameter of this build task.
- *
- * @param filenames Filenames to include as the message body of this email.
- */
- public void setFiles( String filenames )
- throws TaskException
- {
- StringTokenizer t = new StringTokenizer( filenames, ", " );
-
- while( t.hasMoreTokens() )
- {
- files.add( resolveFile( t.nextToken() ) );
- }
- }
-
- /**
- * Sets the from parameter of this build task.
- *
- * @param from Email address of sender.
- */
- public void setFrom( String from )
- {
- this.from = from;
- }
-
- /**
- * Sets Includefilenames attribute
- *
- * @param includefilenames Set to true if file names are to be included.
- * @since 1.5
- */
- public void setIncludefilenames( boolean includefilenames )
- {
- this.includefilenames = includefilenames;
- }
-
- /**
- * Sets the mailhost parameter of this build task.
- *
- * @param mailhost Mail host name.
- */
- public void setMailhost( String mailhost )
- {
- this.mailhost = mailhost;
- }
-
- /**
- * Sets the mailport parameter of this build task.
- *
- * @param value mail port name.
- */
- public void setMailport( Integer value )
- {
- this.mailport = value.intValue();
- }
-
- /**
- * Sets the message parameter of this build task.
- *
- * @param message Message body of this email.
- */
- public void setMessage( String message )
- {
- this.message = message;
- }
-
- /**
- * Sets the subject parameter of this build task.
- *
- * @param subject Subject of this email.
- */
- public void setSubject( String subject )
- {
- this.subject = subject;
- }
-
- /**
- * Sets the toList parameter of this build task.
- *
- * @param toList Comma-separated list of email recipient addreses.
- */
- public void setToList( String toList )
- {
- this.toList = toList;
- }
-
- /**
- * Executes this build task.
- *
- * @throws TaskException if there is an error during task execution.
- */
- public void execute()
- throws TaskException
- {
- try
- {
- MailMessage mailMessage = new MailMessage( mailhost );
- mailMessage.setPort( mailport );
-
- if( from != null )
- {
- mailMessage.from( from );
- }
- else
- {
- throw new TaskException( "Attribute \"from\" is required." );
- }
-
- if( toList != null )
- {
- StringTokenizer t = new StringTokenizer( toList, ", ", false );
-
- while( t.hasMoreTokens() )
- {
- mailMessage.to( t.nextToken() );
- }
- }
- else
- {
- throw new TaskException( "Attribute \"toList\" is required." );
- }
-
- if( subject != null )
- {
- mailMessage.setSubject( subject );
- }
-
- if( !files.isEmpty() )
- {
- PrintStream out = mailMessage.getPrintStream();
-
- for( Iterator e = files.iterator(); e.hasNext(); )
- {
- File file = (File)e.next();
-
- if( file.exists() && file.canRead() )
- {
- int bufsize = 1024;
- int length;
- byte[] buf = new byte[ bufsize ];
- if( includefilenames )
- {
- String filename = file.getName();
- int filenamelength = filename.length();
- out.println( filename );
- for( int star = 0; star < filenamelength; star++ )
- {
- out.print( '=' );
- }
- out.println();
- }
- BufferedInputStream in = null;
- try
- {
- in = new BufferedInputStream(
- new FileInputStream( file ), bufsize );
- while( ( length = in.read( buf, 0, bufsize ) ) != -1 )
- {
- out.write( buf, 0, length );
- }
- if( includefilenames )
- {
- out.println();
- }
- }
- finally
- {
- if( in != null )
- {
- try
- {
- in.close();
- }
- catch( IOException ioe )
- {
- }
- }
- }
-
- }
- else
- {
- throw new TaskException( "File \"" + file.getName()
- + "\" does not exist or is not readable." );
- }
- }
- }
- else if( message != null )
- {
- PrintStream out = mailMessage.getPrintStream();
- out.print( message );
- }
- else
- {
- throw new TaskException( "Attribute \"file\" or \"message\" is required." );
- }
-
- getLogger().info( "Sending email" );
- mailMessage.sendAndClose();
- }
- catch( IOException ioe )
- {
- String err = "IO error sending mail " + ioe.toString();
- if( failOnError )
- {
- throw new TaskException( err, ioe );
- }
- else
- {
- getLogger().error( err );
- }
- }
- }
-
-}
diff --git a/proposal/myrmidon/src/todo/org/apache/tools/mail/MailMessage.java b/proposal/myrmidon/src/todo/org/apache/tools/mail/MailMessage.java
deleted file mode 100644
index 228811992..000000000
--- a/proposal/myrmidon/src/todo/org/apache/tools/mail/MailMessage.java
+++ /dev/null
@@ -1,535 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
- */
-package org.apache.tools.mail;
-
-import java.io.BufferedOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Iterator;
-
-/**
- * A class to help send SMTP email. This class is an improvement on the
- * sun.net.smtp.SmtpClient class found in the JDK. This version has extra
- * functionality, and can be used with JVMs that did not extend from the JDK.
- * It's not as robust as the JavaMail Standard Extension classes, but it's
- * easier to use and easier to install, and has an Open Source license.
- *
- * It can be used like this:
- *
- * Be sure to set the from address, then set the recepient addresses, then set
- * the subject and other headers, then get the PrintStream, then write the
- * message, and finally send and close. The class does minimal error checking
- * internally; it counts on the mail host to complain if there's any
- * malformatted input or out of order execution.
- *
- * An attachment mechanism based on RFC 1521 could be implemented on top of this
- * class. In the meanwhile, JavaMail is the best solution for sending email with
- * attachments.
- *
- * Still to do:
- *
- *
- * The same rules used here would apply to FTP and other Telnet based protocols
- * as well.
- * Attribute
- *
- *
- *
- * Description
- *
- *
- *
- * Required
- *
- *
- *
- *
- *
- *
- *
- *
- *
- * from
- *
- *
- *
- * Email address of sender.
- *
- *
- *
- * Yes
- *
- *
- *
- *
- *
- *
- *
- * mailhost
- *
- *
- *
- * Host name of the mail server.
- *
- *
- *
- * No, default to "localhost"
- *
- *
- *
- *
- *
- *
- *
- * toList
- *
- *
- *
- * Comma-separated list of recipients.
- *
- *
- *
- * Yes
- *
- *
- *
- *
- *
- *
- *
- * subject
- *
- *
- *
- * Email subject line.
- *
- *
- *
- * No
- *
- *
- *
- *
- *
- *
- *
- * files
- *
- *
- *
- * Filename(s) of text to send in the body of the email. Multiple files
- * are comma-separated.
- *
- *
- *
- *
- *
- *
- *
- *
- *
- * message
- *
- *
- *
- * Message to send inthe body of the email.
- *
- *
- *
- *
- *
- *
- * includefilenames
- *
- *
- *
- * Includes filenames before file contents when set to true.
- *
- *
- *
- * No, default is false
- *
- *
- *
- * String mailhost = "localhost"; // or another mail host
- * String from = "Mail Message Servlet <MailMessage@server.com>";
- * String to = "to@you.com";
- * String cc1 = "cc1@you.com";
- * String cc2 = "cc2@you.com";
- * String bcc = "bcc@you.com";
- *
- * MailMessage msg = new MailMessage(mailhost);
- * msg.setPort(25);
- * msg.from(from);
- * msg.to(to);
- * msg.cc(cc1);
- * msg.cc(cc2);
- * msg.bcc(bcc);
- * msg.setSubject("Test subject");
- * PrintStream out = msg.getPrintStream();
- *
- * Iterator enum = req.getParameterNames();
- * while (enum.hasNext()) {
- * String name = (String)enum.next();
- * String value = req.getParameter(name);
- * out.println(name + " = " + value);
- * }
- *
- * msg.sendAndClose();
- *
- *
- *
- *
- * @author Jason Hunter
- * @version 1.1, 2000/03/19, added angle brackets to address, helps some servers
- * version 1.0, 1999/12/29
- */
-public class MailMessage
-{
-
- /**
- * default port for SMTP: 25
- */
- public final static int DEFAULT_PORT = 25;
-
- /**
- * host port for the mail server
- */
- private int port = DEFAULT_PORT;
-
- /**
- * list of email addresses to cc to
- */
- private ArrayList cc;
-
- /**
- * sender email address
- */
- private String from;
-
- /**
- * headers to send in the mail
- */
- private Hashtable headers;
-
- /**
- * host name for the mail server
- */
- private String host;
-
- private SmtpResponseReader in;
-
- private MailPrintStream out;
-
- private Socket socket;
-
- /**
- * list of email addresses to send to
- */
- private ArrayList to;
-
- /**
- * Constructs a new MailMessage to send an email. Use localhost as the mail
- * server.
- *
- * @exception IOException if there's any problem contacting the mail server
- */
- public MailMessage()
- throws IOException
- {
- this( "localhost" );
- }
-
- /**
- * Constructs a new MailMessage to send an email. Use the given host as the
- * mail server.
- *
- * @param host the mail server to use
- * @exception IOException if there's any problem contacting the mail server
- */
- public MailMessage( String host )
- throws IOException
- {
- this.host = host;
- to = new ArrayList();
- cc = new ArrayList();
- headers = new Hashtable();
- setHeader( "X-Mailer", "org.apache.tools.mail.MailMessage (jakarta.apache.org)" );
- connect();
- sendHelo();
- }
-
- // Make a limited attempt to extract a sanitized email address
- // Prefer text in
- * Attribute
- *
- *
- *
- * Description
- *
- *
- *
- * Required
- *
- *
- *
- *
- *
- *
- *
- *
- *
- * from
- *
- *
- *
- * Email address of sender.
- *
- *
- *
- * Yes
- *
- *
- *
- *
- *
- *
- *
- * mailhost
- *
- *
- *
- * Host name of the mail server.
- *
- *
- *
- * No, default to "localhost"
- *
- *
- *
- *
- *
- *
- *
- * toList
- *
- *
- *
- * Comma-separated list of recipients.
- *
- *
- *
- * Yes
- *
- *
- *
- *
- *
- *
- *
- * subject
- *
- *
- *
- * Email subject line.
- *
- *
- *
- * No
- *
- *
- *
- *
- *
- *
- *
- * files
- *
- *
- *
- * Filename(s) of text to send in the body of the email. Multiple files
- * are comma-separated.
- *
- *
- *
- *
- *
- *
- *
- *
- *
- * message
- *
- *
- *
- * Message to send inthe body of the email.
- *
- *
- *
- *
- *
- *
- * includefilenames
- *
- *
- *
- * Includes filenames before file contents when set to true.
- *
- *
- *
- * No, default is false
- *
- *
- *
- * String mailhost = "localhost"; // or another mail host
- * String from = "Mail Message Servlet <MailMessage@server.com>";
- * String to = "to@you.com";
- * String cc1 = "cc1@you.com";
- * String cc2 = "cc2@you.com";
- * String bcc = "bcc@you.com";
- *
- * MailMessage msg = new MailMessage(mailhost);
- * msg.setPort(25);
- * msg.from(from);
- * msg.to(to);
- * msg.cc(cc1);
- * msg.cc(cc2);
- * msg.bcc(bcc);
- * msg.setSubject("Test subject");
- * PrintStream out = msg.getPrintStream();
- *
- * Iterator enum = req.getParameterNames();
- * while (enum.hasNext()) {
- * String name = (String)enum.next();
- * String value = req.getParameter(name);
- * out.println(name + " = " + value);
- * }
- *
- * msg.sendAndClose();
- *
- *
- *
- *
- * @author Jason Hunter
- * @version 1.1, 2000/03/19, added angle brackets to address, helps some servers
- * version 1.0, 1999/12/29
- */
-public class MailMessage
-{
-
- /**
- * default port for SMTP: 25
- */
- public final static int DEFAULT_PORT = 25;
-
- /**
- * host port for the mail server
- */
- private int port = DEFAULT_PORT;
-
- /**
- * list of email addresses to cc to
- */
- private ArrayList cc;
-
- /**
- * sender email address
- */
- private String from;
-
- /**
- * headers to send in the mail
- */
- private Hashtable headers;
-
- /**
- * host name for the mail server
- */
- private String host;
-
- private SmtpResponseReader in;
-
- private MailPrintStream out;
-
- private Socket socket;
-
- /**
- * list of email addresses to send to
- */
- private ArrayList to;
-
- /**
- * Constructs a new MailMessage to send an email. Use localhost as the mail
- * server.
- *
- * @exception IOException if there's any problem contacting the mail server
- */
- public MailMessage()
- throws IOException
- {
- this( "localhost" );
- }
-
- /**
- * Constructs a new MailMessage to send an email. Use the given host as the
- * mail server.
- *
- * @param host the mail server to use
- * @exception IOException if there's any problem contacting the mail server
- */
- public MailMessage( String host )
- throws IOException
- {
- this.host = host;
- to = new ArrayList();
- cc = new ArrayList();
- headers = new Hashtable();
- setHeader( "X-Mailer", "org.apache.tools.mail.MailMessage (jakarta.apache.org)" );
- connect();
- sendHelo();
- }
-
- // Make a limited attempt to extract a sanitized email address
- // Prefer text in