You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jakarta.apache.org by se...@apache.org on 2010/07/06 15:37:43 UTC

svn commit: r960896 - in /jakarta/jmeter/trunk/src: core/org/apache/jmeter/resources/ protocol/mail/org/apache/jmeter/protocol/smtp/sampler/ protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/ protocol/mail/org/apache/jmeter/protocol/smtp/sample...

Author: sebb
Date: Tue Jul  6 13:37:43 2010
New Revision: 960896

URL: http://svn.apache.org/viewvc?rev=960896&view=rev
Log:
Fix thread-unsafe local truststore setup
Ensure StartTLS can be used with TrustAll and UseLocal
Use starttls.require property instead of debug hack for EnforceStartTLS
These require properties which are available from JavaMail 1.4.2+
Add debug logging checkbox

Modified:
    jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
    jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java
    jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java
    jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java
    jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/protocol/SendMailCommand.java

Modified: jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties?rev=960896&r1=960895&r2=960896&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties (original)
+++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties Tue Jul  6 13:37:43 2010
@@ -797,6 +797,7 @@ smtp_bcc=Address To BCC:
 smtp_cc=Address To CC:
 smtp_default_port=(Defaults: SMTP:25, SSL:465, StartTLS:587)
 smtp_eml=Send .eml:
+smtp_enabledebug=Enable debug logging?
 smtp_enforcestarttls=Enforce StartTLS
 smtp_enforcestarttls_tooltip=<html><b>Enforces</b> the server to use StartTLS.<br />If not selected and the SMTP-Server doesn't support StartTLS, <br />a normal SMTP-Connection will be used as fallback instead. <br /><i>Please note</i> that this checkbox creates a file in \"/tmp/\", <br />so this will cause problems under windows.</html>
 smtp_from=Address From:

Modified: jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java?rev=960896&r1=960895&r2=960896&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java (original)
+++ jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java Tue Jul  6 13:37:43 2010
@@ -77,6 +77,7 @@ public class SmtpSampler extends Abstrac
     public final static String TRUSTSTORE_TO_USE    = "SMTPSampler.trustStoreToUse"; // $NON-NLS-1$
     public final static String USE_EML              = "SMTPSampler.use_eml"; // $NON-NLS-1$
     public final static String EML_MESSAGE_TO_SEND  = "SMTPSampler.emlMessageToSend"; // $NON-NLS-1$
+    public static final String ENABLE_DEBUG         = "SMTPSampler.enableDebug"; // $NON-NLS-1$
 
     // Used to separate attachment file names in JMX fields - do not change!
     public static final String FILENAME_SEPARATOR = ";";
@@ -117,6 +118,8 @@ public class SmtpSampler extends Abstrac
         instance.setEmlMessage(getPropertyAsString(EML_MESSAGE_TO_SEND));
         instance.setUseEmlMessage(getPropertyAsBoolean(USE_EML));
 
+        instance.setEnableDebug(getPropertyAsBoolean(ENABLE_DEBUG));
+
         if (getPropertyAsString(MAIL_FROM).matches(".*@.*")) {
             instance.setSender(getPropertyAsString(MAIL_FROM));
         }
@@ -126,14 +129,13 @@ public class SmtpSampler extends Abstrac
         final String receiverBcc = getPropertyAsString(SmtpSampler.RECEIVER_BCC).trim();
 
         try {
-            
             // Process address lists
             instance.setReceiverTo(getPropNameAsAddresses(receiverTo));
             instance.setReceiverCC(getPropNameAsAddresses(receiverCC));
             instance.setReceiverBCC(getPropNameAsAddresses(receiverBcc));
 
             instance.setSubject(getPropertyAsString(SUBJECT)
-                    + (getPropertyAsBoolean(INCLUDE_TIMESTAMP) ? 
+                    + (getPropertyAsBoolean(INCLUDE_TIMESTAMP) ?
                             " <<< current timestamp: " + new Date().getTime() + " >>>"
                             : ""
                        ));
@@ -190,8 +192,8 @@ public class SmtpSampler extends Abstrac
 
             // Set up the sample result details
             res.setSamplerData(
-                    "To: " + receiverTo 
-                    + "\nCC: " + receiverCC 
+                    "To: " + receiverTo
+                    + "\nCC: " + receiverCC
                     + "\nBCC: " + receiverBcc);
             res.setDataType(SampleResult.TEXT);
             res.setResponseCodeOK();
@@ -269,7 +271,7 @@ public class SmtpSampler extends Abstrac
      * Null is treated differently from an empty list.
      * @param propValue addresses separated by ";"
      * @return the list or null if the input was the empty string
-     * @throws AddressException 
+     * @throws AddressException
      */
     private List<InternetAddress> getPropNameAsAddresses(String propValue) throws AddressException{
         if (propValue.length() > 0){ // we have at least one potential address
@@ -277,9 +279,9 @@ public class SmtpSampler extends Abstrac
             for (String address : propValue.split(";")){
                 addresses.add(new InternetAddress(address.trim()));
             }
-            return addresses;            
+            return addresses;
         } else {
-            return null;            
+            return null;
         }
     }
 }
\ No newline at end of file

Modified: jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java?rev=960896&r1=960895&r2=960896&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java (original)
+++ jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java Tue Jul  6 13:37:43 2010
@@ -91,6 +91,7 @@ public class SmtpPanel extends JPanel {
     private JTextField tfSubject;
     private JCheckBox cbIncludeTimestamp;
     private JCheckBox cbMessageSizeStats;
+    private JCheckBox cbEnableDebug;
     private JCheckBox cbUseEmlMessage;
 
     /**
@@ -284,7 +285,7 @@ public class SmtpPanel extends JPanel {
 
     /**
      * Set whether mail server needs auth.
-     * 
+     *
      * @param selected
      */
     public void setUseAuth(boolean selected){
@@ -353,6 +354,14 @@ public class SmtpPanel extends JPanel {
         cbEnforceStartTLS.setSelected(enforceStartTLS);
     }
 
+    public boolean isEnableDebug() {
+        return cbEnableDebug.isSelected();
+    }
+
+    public void setEnableDebug(boolean selected){
+        cbEnableDebug.setSelected(selected);
+    }
+
     /**
      * Returns if all certificates are blindly trusted (using according
      * SocketFactory) (checkbox)
@@ -499,10 +508,6 @@ public class SmtpPanel extends JPanel {
         cbMessageSizeStats.setSelected(val);
     }
 
-    public JRadioButton isUseNoSecurity() {
-        return rbUseNone;
-    }
-
     public void setUseNoSecurity(boolean selected) {
         rbUseNone.setSelected(selected);
     }
@@ -567,6 +572,7 @@ public class SmtpPanel extends JPanel {
         cbEnforceStartTLS = new JCheckBox(JMeterUtils.getResString("smtp_enforcestarttls")); // $NON-NLS-1$
         cbIncludeTimestamp = new JCheckBox(JMeterUtils.getResString("smtp_timestamp")); // $NON-NLS-1$
         cbMessageSizeStats = new JCheckBox(JMeterUtils.getResString("smtp_messagesize")); // $NON-NLS-1$
+        cbEnableDebug = new JCheckBox(JMeterUtils.getResString("smtp_enabledebug")); // $NON-NLS-1$
         cbUseLocalTrustStore = new JCheckBox(JMeterUtils.getResString("smtp_usetruststore")); // $NON-NLS-1$
         cbUseEmlMessage = new JCheckBox(JMeterUtils.getResString("smtp_eml")); // $NON-NLS-1$
 
@@ -606,7 +612,7 @@ public class SmtpPanel extends JPanel {
          */
         JPanel panelServerSettings = new JPanel(new GridBagLayout());
         panelServerSettings.setBorder(BorderFactory.createTitledBorder(
-                BorderFactory.createEtchedBorder(), 
+                BorderFactory.createEtchedBorder(),
                 JMeterUtils.getResString("smtp_server_settings"))); // $NON-NLS-1$
 
         gridBagConstraints.gridx = 0;
@@ -643,7 +649,7 @@ public class SmtpPanel extends JPanel {
          */
         JPanel panelMailSettings = new JPanel(new GridBagLayout());
         panelMailSettings.setBorder(BorderFactory.createTitledBorder(
-                BorderFactory.createEtchedBorder(), 
+                BorderFactory.createEtchedBorder(),
                 JMeterUtils.getResString("smtp_mail_settings"))); // $NON-NLS-1$
 
         gridBagConstraints.gridx = 0;
@@ -687,11 +693,10 @@ public class SmtpPanel extends JPanel {
          */
         JPanel panelAuthSettings = new JPanel(new GridBagLayout());
         panelAuthSettings.setBorder(BorderFactory.createTitledBorder(
-                BorderFactory.createEtchedBorder(), 
+                BorderFactory.createEtchedBorder(),
                 JMeterUtils.getResString("smtp_auth_settings"))); // $NON-NLS-1$
 
-        cbUseAuth.setBorder(BorderFactory.createEmptyBorder(0, 0,
-                0, 0));
+        cbUseAuth.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
         cbUseAuth.setMargin(new java.awt.Insets(0, 0, 0, 0));
         cbUseAuth.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent evt) {
@@ -732,7 +737,7 @@ public class SmtpPanel extends JPanel {
          */
         JPanel panelSecuritySettings = new JPanel(new GridBagLayout());
         panelSecuritySettings.setBorder(BorderFactory.createTitledBorder(
-                BorderFactory.createEtchedBorder(), 
+                BorderFactory.createEtchedBorder(),
                 JMeterUtils.getResString("smtp_security_settings"))); // $NON-NLS-1$
 
         rbUseNone.setSelected(true);
@@ -831,7 +836,7 @@ public class SmtpPanel extends JPanel {
          */
         JPanel panelMessageSettings = new JPanel(new GridBagLayout());
         panelMessageSettings.setBorder(BorderFactory.createTitledBorder(
-                BorderFactory.createEtchedBorder(), 
+                BorderFactory.createEtchedBorder(),
                 JMeterUtils.getResString("smtp_message_settings"))); // $NON-NLS-1$
 
         gridBagConstraints.gridx = 0;
@@ -912,17 +917,20 @@ public class SmtpPanel extends JPanel {
          */
         JPanel panelAdditionalSettings = new JPanel(new GridBagLayout());
         panelAdditionalSettings.setBorder(BorderFactory.createTitledBorder(
-                BorderFactory.createEtchedBorder(), 
+                BorderFactory.createEtchedBorder(),
                 JMeterUtils.getResString("smtp_additional_settings"))); // $NON-NLS-1$
 
-        cbMessageSizeStats.setBorder(BorderFactory
-                .createEmptyBorder(0, 0, 0, 0));
+        cbMessageSizeStats.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
         cbMessageSizeStats.setMargin(new java.awt.Insets(0, 0, 0, 0));
 
         gridBagConstraints.gridx = 0;
         gridBagConstraints.gridy = 0;
         panelAdditionalSettings.add(cbMessageSizeStats, gridBagConstraints);
 
+        gridBagConstraints.gridx = 1;
+        gridBagConstraints.gridy = 0;
+        panelAdditionalSettings.add(cbEnableDebug, gridBagConstraints);
+
         gridBagConstraintsMain.gridx = 0;
         gridBagConstraintsMain.gridy = 5;
         add(panelAdditionalSettings, gridBagConstraintsMain);
@@ -1097,6 +1105,7 @@ public class SmtpPanel extends JPanel {
     public void clear() {
         cbIncludeTimestamp.setSelected(false);
         cbMessageSizeStats.setSelected(false);
+        cbEnableDebug.setSelected(false);
         cbUseEmlMessage.setSelected(false);
         cbUseAuth.setSelected(false);
         taMessage.setText("");

Modified: jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java?rev=960896&r1=960895&r2=960896&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java (original)
+++ jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java Tue Jul  6 13:37:43 2010
@@ -94,6 +94,7 @@ public class SmtpSamplerGui extends Abst
         smtpPanel.setPassword(element.getPropertyAsString(SmtpSampler.PASSWORD));
 
         smtpPanel.setMessageSizeStatistic(element.getPropertyAsBoolean(SmtpSampler.MESSAGE_SIZE_STATS));
+        smtpPanel.setEnableDebug(element.getPropertyAsBoolean(SmtpSampler.ENABLE_DEBUG));
 
         super.configure(element);
     }
@@ -143,6 +144,7 @@ public class SmtpSamplerGui extends Abst
         te.setProperty(SmtpSampler.USERNAME, smtpPanel.getUsername());
 
         te.setProperty(SmtpSampler.MESSAGE_SIZE_STATS, Boolean.toString(smtpPanel.isMessageSizeStatistics()));
+        te.setProperty(SmtpSampler.ENABLE_DEBUG, Boolean.toString(smtpPanel.isEnableDebug()));
     }
 
     /**

Modified: jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/protocol/SendMailCommand.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/protocol/SendMailCommand.java?rev=960896&r1=960895&r2=960896&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/protocol/SendMailCommand.java (original)
+++ jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/protocol/SendMailCommand.java Tue Jul  6 13:37:43 2010
@@ -18,14 +18,9 @@
 
 package org.apache.jmeter.protocol.smtp.sampler.protocol;
 
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -58,7 +53,7 @@ public class SendMailCommand {
 
     // local vars
     private static final Logger logger = LoggingManager.getLoggerForClass();
-    
+
     // Use the actual class so the name must be correct.
     private static final String TRUST_ALL_SOCKET_FACTORY = TrustAllSSLSocketFactory.class.getName();
 
@@ -66,8 +61,8 @@ public class SendMailCommand {
     private boolean useStartTLS = false;
     private boolean trustAllCerts = false;
     private boolean enforceStartTLS = false;
-    private boolean startTLSSuccessful = false;
     private boolean sendEmlMessage = false;
+    private boolean enableDebug;
     private String smtpServer;
     private String smtpPort;
     private String sender;
@@ -89,10 +84,6 @@ public class SendMailCommand {
 
     private String mailBody;
 
-    // needed to check starttls functionality
-    private PrintStream debugOutStream;
-    private BufferedReader debugReader;
-
     // case we are measuring real time of spedition
     private boolean synchronousMode;
 
@@ -114,8 +105,8 @@ public class SendMailCommand {
      * properties such as protocol, authentication, etc.
      *
      * @return Message-object to be sent to execute()-method
-     * @throws MessagingException 
-     * @throws IOException 
+     * @throws MessagingException
+     * @throws IOException
      */
     public Message prepareMessage() throws MessagingException, IOException {
 
@@ -124,20 +115,51 @@ public class SendMailCommand {
         String protocol = getProtocol();
 
         // set properties using JAF
-        props.put("mail." + protocol + ".host", smtpServer);
-        props.put("mail." + protocol + ".port", getPort());
-        props.put("mail." + protocol + ".auth", Boolean.toString(useAuthentication));
-//        props.put("mail.debug","true");
+        props.setProperty("mail." + protocol + ".host", smtpServer);
+        props.setProperty("mail." + protocol + ".port", getPort());
+        props.setProperty("mail." + protocol + ".auth", Boolean.toString(useAuthentication));
+
+        if (enableDebug) {
+            props.setProperty("mail.debug","true");
+        }
 
         if (useStartTLS) {
-            props.put("mail.smtp.starttls.enable", "true");
-            //props.put("mail.debug", "true");
+            props.setProperty("mail.smtp.starttls.enable", "true");
+            if (enforceStartTLS){
+                // Requires JavaMail 1.4.2+
+                props.setProperty("mail.smtp.starttls.require", "true");
+            }
         }
 
-        if (trustAllCerts && useSSL) {
-            props.setProperty("mail.smtps.socketFactory.class",
-                    TRUST_ALL_SOCKET_FACTORY);
-            props.setProperty("mail.smtps.socketFactory.fallback", "false");
+        if (trustAllCerts) {
+            if (useSSL) {
+                props.setProperty("mail.smtps.ssl.socketFactory.class", TRUST_ALL_SOCKET_FACTORY);
+                props.setProperty("mail.smtps.ssl.socketFactory.fallback", "false");
+            } else if (useStartTLS) {
+                props.setProperty("mail.smtp.ssl.socketFactory.class", TRUST_ALL_SOCKET_FACTORY);
+                props.setProperty("mail.smtp.ssl.socketFactory.fallback", "false");
+            }
+        } else if (useLocalTrustStore){
+            File truststore = new File(trustStoreToUse);
+            logger.info("load local truststore - try to load truststore from: "+truststore.getAbsolutePath());
+            if(!truststore.exists()){
+                logger.info("load local truststore -Failed to load truststore from: "+truststore.getAbsolutePath());
+                truststore = new File(FileServer.getFileServer().getBaseDir(), trustStoreToUse);
+                logger.info("load local truststore -Attempting to read truststore from:  "+truststore.getAbsolutePath());
+                if(!truststore.exists()){
+                    logger.info("load local truststore -Failed to load truststore from: "+truststore.getAbsolutePath() + ". Local truststore not available, aborting execution.");
+                    throw new IOException("Local truststore file not found. Also not available under : " + truststore.getAbsolutePath());
+                }
+            }
+            if (useSSL) {
+                // Requires JavaMail 1.4.2+
+                props.put("mail.smtps.ssl.socketFactory", new LocalTrustStoreSSLSocketFactory(truststore));
+                props.put("mail.smtps.ssl.socketFactory.fallback", "false");
+            } else if (useStartTLS) {
+                // Requires JavaMail 1.4.2+
+                props.put("mail.smtp.ssl.socketFactory", new LocalTrustStoreSSLSocketFactory(truststore));
+                props.put("mail.smtp.ssl.socketFactory.fallback", "false");
+            }
         }
 
         session = Session.getInstance(props, null);
@@ -166,6 +188,7 @@ public class SendMailCommand {
         if (null != sender) {
             message.setFrom(new InternetAddress(sender));
         }
+
         if (null != subject) {
             message.setSubject(subject);
         }
@@ -177,7 +200,6 @@ public class SendMailCommand {
         }
 
         if (receiverCC != null) {
-
             InternetAddress[] cc = new InternetAddress[receiverCC.size()];
             receiverCC.toArray(cc);
             message.setRecipients(Message.RecipientType.CC, cc);
@@ -198,53 +220,16 @@ public class SendMailCommand {
     }
 
     /**
-     * Sends message to mailserver, including all necessary tasks. Contains 2
-     * ugly hacks to ensure the use of StartTLS if needed (see comments "UGLY
-     * HACK X") where logfiles are monitored
+     * Sends message to mailserver, waiting for delivery if using synchronous mode.
      *
      * @param message
      *            Message prior prepared by prepareMessage()
-     * @throws MessagingException 
-     * @throws IOException 
-     * @throws InterruptedException 
+     * @throws MessagingException
+     * @throws IOException
+     * @throws InterruptedException
      */
     public void execute(Message message) throws MessagingException, IOException, InterruptedException {
 
-        // TODO change to use thread-safe method
-/*
- * Reduce impact on other threads - don't clear the setting each time.
- * Won't work with samplers that use both settings of the option, but they won't work reliably anyway across threads.
- * 
- * With this change, the code should be thread-safe if the user does not select useLocalTrustStore.
- * 
- *         System.clearProperty("javax.net.ssl.trustStore");
- */
-
-        if (useLocalTrustStore) {
-            File truststore = new File(trustStoreToUse);
-            logger.info("load local truststore - try to load truststore from: "+truststore.getAbsolutePath());
-            if(!truststore.exists()){
-                logger.info("load local truststore -Failed to load truststore from: "+truststore.getAbsolutePath());
-                truststore = new File(FileServer.getFileServer().getBaseDir(), trustStoreToUse);
-                logger.info("load local truststore -Attempting to read truststore from:  "+truststore.getAbsolutePath());
-                if(!truststore.exists()){
-                    logger.info("load local truststore -Failed to load truststore from: "+truststore.getAbsolutePath() + ". Local truststore not available, aborting execution.");
-                    throw new IOException("Local truststore file not found. Also not available under : " + truststore.getAbsolutePath());
-                }
-            }
-            logger.warn("Setting javax.net.ssl.trustStore - may affect the behaviour of other threads");
-            System.setProperty("javax.net.ssl.trustStore", truststore.getAbsolutePath());
-        }
-
-        /*
-         * UGLY HACK 1: redirect session-DebugOutput to ensure
-         * StartTLS-Support
-         */
-        ByteArrayOutputStream debugOutputStream = new ByteArrayOutputStream();
-        debugOutStream = new PrintStream(debugOutputStream);
-        session.setDebugOut(debugOutStream);
-        session.setDebug(true);
-
         Transport tr = session.getTransport(getProtocol());
         SynchronousTransportListener listener = null;
 
@@ -268,34 +253,6 @@ public class SendMailCommand {
         tr.close();
         logger.debug("transport closed");
 
-        /*
-         * UGLY HACK 2: read from redirected debug-output
-         */
-        debugOutStream.flush();
-        debugReader = new BufferedReader(new InputStreamReader(
-                new ByteArrayInputStream(debugOutputStream.toByteArray())));
-        String line;
-        int i = 0;
-        while ((line = debugReader.readLine()) != null) {
-            logger.debug("server line " + i + ": " + line);
-            // unusable for the astf runs bom
-            //serverResponse.append(line);
-            //serverResponse.append("\n");
-            if (line.matches(".*Ready to start TLS.*")) {
-                if (useStartTLS && enforceStartTLS) {
-                    startTLSSuccessful = true;
-                }
-            }
-        }
-        debugReader.close();
-        debugOutStream.close();
-        session.setDebugOut(System.out);
-        if (useStartTLS && enforceStartTLS) {
-            if (!startTLSSuccessful) {
-                throw new MessagingException("StartTLS failed");
-            }
-        }
-
         logger.debug("message sent");
         return;
     }
@@ -700,7 +657,7 @@ public class SendMailCommand {
     /**
      * Returns port to be used for SMTP-connection - returns the
      * default port for the protocol if no port has been supplied.
-     * 
+     *
      * @return Port to be used for SMTP-connection
      */
     private String getPort() {
@@ -755,7 +712,7 @@ public class SendMailCommand {
 
     /**
      * Set the mail body.
-     * 
+     *
      * @param body
      */
     public void setMailBody(String body){
@@ -765,4 +722,9 @@ public class SendMailCommand {
     public StringBuffer getServerResponse() {
         return this.serverResponse;
     }
+
+    public void setEnableDebug(boolean selected) {
+        enableDebug = selected;
+
+    }
 }
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@jakarta.apache.org
For additional commands, e-mail: notifications-help@jakarta.apache.org