org.apache.jmeter.protocol.smtp.sampler.protocol

## Class SendMailCommand

- java.lang.Object
- - org.apache.jmeter.protocol.smtp.sampler.protocol.SendMailCommand

-     public class SendMailCommand
      extends java.lang.Object

  This class performs all tasks necessary to send a message (build message, prepare connection, send message). Provides getter-/setter-methods for an SmtpSampler-object to configure transport and message settings. The send-mail-command itself is started by the SmtpSampler-object.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SendMailCommand()` Standard-Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addAttachment(java.io.File attachment)` Adds an attachment to current message - to be called by SmtpSampler-object
    `void` | `addHeader(java.lang.String headerName, java.lang.String headerValue)` Adds a header-part to current HashMap of headers - to be called by SmtpSampler-object
    `void` | `clearAttachments()` Clear all attachments for current message
    `void` | `clearHeaders()` Deletes all current headers in HashMap
    `void` | `execute()` Processes prepareMessage() and execute()
    `void` | `execute(javax.mail.Message message)` Sends message to mailserver, waiting for delivery if using synchronous mode.
    `java.util.List<java.io.File>` | `getAttachments()` Returns all attachment for current message - standard getter
    `java.lang.String` | `getConnectionTimeout()` Returns connection timeout for the SMTP-connection - returns the default connection timeout if no value has been supplied.
    `CollectionProperty` | `getHeaders()` Returns headers for current message - standard getter
    `java.lang.String` | `getPassword()` Returns password to authenticate at the mailserver - standard getter
    `java.util.List<javax.mail.internet.InternetAddress>` | `getReceiverBCC()` Returns receivers of current message as `InternetAddress` ("bcc") - standard getter
    `java.util.List<javax.mail.internet.InternetAddress>` | `getReceiverCC()` Returns receivers of current message as `InternetAddress` ("cc") - standard getter
    `java.lang.String` | `getSender()` Returns sender-address for current message - standard getter
    `java.lang.String` | `getSmtpPort()` Returns port to be used for SMTP-connection (standard 25 or 465) - standard getter
    `java.lang.String` | `getSmtpServer()` Returns FQDN or IP of SMTP-server to be used to send message - standard getter
    `java.lang.String` | `getSubject()` Returns subject for current message - standard getter
    `java.lang.String` | `getTimeout()` Returns timeout for the SMTP-connection - returns the default timeout if no value has been supplied.
    `java.lang.String` | `getUsername()` Returns username to authenticate at the mailserver - standard getter
    `boolean` | `getUseSSL()` Returns if SSL is used to send message - standard getter
    `boolean` | `getUseStartTLS()` Returns if StartTLS is used to transmit message - standard getter
    `boolean` | `isEnforceStartTLS()` Returns if StartTLS is enforced to secure the connection, i.e. no fallback is used (plain SMTP) - standard getter
    `boolean` | `isSynchronousMode()` Returns if synchronous-mode is used for current message (i.e. time for delivery, ... is measured) - standard getter
    `boolean` | `isTrustAllCerts()` Returns if sampler should trust all certificates - standard getter
    `boolean` | `isUseAuthentication()` Returns if authentication is used to access the mailserver - standard getter
    `javax.mail.Message` | `prepareMessage()` Prepares message prior to be sent via execute()-method, i.e. sets properties such as protocol, authentication, etc.
    `void` | `setAttachments(java.util.List<java.io.File> attachments)` Adds attachments to current message
    `void` | `setConnectionTimeOut(java.lang.String connectionTimeOut)`
    `void` | `setEmlMessage(java.lang.String emlMessage)` Sets eml-message to be sent
    `void` | `setEnableDebug(boolean selected)`
    `void` | `setEnforceStartTLS(boolean enforceStartTLS)` Instructs object to enforce StartTLS and not to fallback to plain SMTP-connection - to be called by SmtpSampler-object
    `void` | `setHeaderFields(CollectionProperty headerFields)` Sets headers for current message
    `void` | `setMailBody(java.lang.String body)` Set the mail body.
    `void` | `setPassword(java.lang.String password)` Sets password to authenticate at the mailserver - to be called by SmtpSampler-object
    `void` | `setPlainBody(boolean plainBody)` Set whether to send a plain body (i.e. not multipart/mixed)
    `void` | `setReceiverBCC(java.util.List<javax.mail.internet.InternetAddress> receiverBCC)` Sets receivers of current message ("bcc") - to be called by SmtpSampler-object
    `void` | `setReceiverCC(java.util.List<javax.mail.internet.InternetAddress> receiverCC)` Sets receivers of current message ("cc") - to be called by SmtpSampler-object
    `void` | `setReceiverTo(java.util.List<javax.mail.internet.InternetAddress> receiverTo)` Sets receivers of current message ("to") - to be called by SmtpSampler-object
    `void` | `setReplyTo(java.util.List<javax.mail.internet.InternetAddress> replyTo)`
    `void` | `setSender(java.lang.String sender)` Sets the sender-address for the current message - to be called by SmtpSampler-object
    `void` | `setSmtpPort(java.lang.String smtpPort)` Sets port to be used for SMTP-connection (standard 25 or 465) - to be called by SmtpSampler-object
    `void` | `setSmtpServer(java.lang.String smtpServer)` Sets FQDN or IP of SMTP-server to be used to send message - to be called by SmtpSampler-object
    `void` | `setSubject(java.lang.String subject)` Sets subject for current message - called by SmtpSampler-object
    `void` | `setSynchronousMode(boolean synchronousMode)` Sets the use of synchronous-mode (i.e. time for delivery, ... is measured) - to be called by SmtpSampler-object
    `void` | `setTimeOut(java.lang.String timeOut)`
    `void` | `setTrustAllCerts(boolean trustAllCerts)` Determines if SMTP-sampler should trust all certificates, no matter what CA - to be called by SmtpSampler-object
    `void` | `setTrustStoreToUse(java.lang.String trustStoreToUse)` Sets the path to the local truststore to be used for SSL / StartTLS - to be called by SmtpSampler-object
    `void` | `setUseAuthentication(boolean useAuthentication)` Sets if authentication should be used to access the mailserver - to be called by SmtpSampler-object
    `void` | `setUseEmlMessage(boolean sendEmlMessage)`
    `void` | `setUseLocalTrustStore(boolean useLocalTrustStore)` Assigns the object to use a local truststore for SSL / StartTLS - to be called by SmtpSampler-object
    `void` | `setUsername(java.lang.String username)` Sets username to authenticate at the mailserver - to be called by SmtpSampler-object
    `void` | `setUseSSL(boolean useSSL)` Sets SSL to secure the delivery channel for the message - to be called by SmtpSampler-object
    `void` | `setUseStartTLS(boolean useStartTLS)` Sets StartTLS to secure the delivery channel for the message - to be called by SmtpSampler-object

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SendMailCommand

          public SendMailCommand()

      Standard-Constructor

  - ### Method Detail

    - #### prepareMessage

          public javax.mail.Message prepareMessage()
                                            throws javax.mail.MessagingException,
                                                   java.io.IOException

      Prepares message prior to be sent via execute()-method, i.e. sets properties such as protocol, authentication, etc.
      Returns:
        Message-object to be sent to execute()-method
      Throws:
        `javax.mail.MessagingException` - when problems constructing or sending the mail occur
        `java.io.IOException` - when the mail content can not be read or truststore problems are detected

    - #### execute

          public void execute(javax.mail.Message message)
                       throws javax.mail.MessagingException,
                              java.lang.InterruptedException

      Sends message to mailserver, waiting for delivery if using synchronous mode.
      Parameters:
        `message` - Message previously prepared by prepareMessage()
      Throws:
        `javax.mail.MessagingException` - when problems sending the mail arise
        `java.lang.InterruptedException` - when interrupted while waiting for delivery in synchronous mode

    - #### execute

          public void execute()
                       throws javax.mail.MessagingException,
                              java.io.IOException,
                              java.lang.InterruptedException

      Processes prepareMessage() and execute()
      Throws:
        `java.lang.InterruptedException` - when interrupted while waiting for delivery in synchronous modus
        `java.io.IOException` - when the mail content can not be read or truststore problems are detected
        `javax.mail.MessagingException` - when problems constructing or sending the mail occur

    - #### getSmtpServer

          public java.lang.String getSmtpServer()

      Returns FQDN or IP of SMTP-server to be used to send message - standard getter
      Returns:
        FQDN or IP of SMTP-server

    - #### setSmtpServer

          public void setSmtpServer(java.lang.String smtpServer)

      Sets FQDN or IP of SMTP-server to be used to send message - to be called by SmtpSampler-object
      Parameters:
        `smtpServer` - FQDN or IP of SMTP-server

    - #### getSender

          public java.lang.String getSender()

      Returns sender-address for current message - standard getter
      Returns:
        sender-address

    - #### setSender

          public void setSender(java.lang.String sender)

      Sets the sender-address for the current message - to be called by SmtpSampler-object
      Parameters:
        `sender` - Sender-address for current message

    - #### getSubject

          public java.lang.String getSubject()

      Returns subject for current message - standard getter
      Returns:
        Subject of current message

    - #### setSubject

          public void setSubject(java.lang.String subject)

      Sets subject for current message - called by SmtpSampler-object
      Parameters:
        `subject` - Subject for message of current message - may be null

    - #### getUsername

          public java.lang.String getUsername()

      Returns username to authenticate at the mailserver - standard getter
      Returns:
        Username for mailserver

    - #### setUsername

          public void setUsername(java.lang.String username)

      Sets username to authenticate at the mailserver - to be called by SmtpSampler-object
      Parameters:
        `username` - Username for mailserver

    - #### getPassword

          public java.lang.String getPassword()

      Returns password to authenticate at the mailserver - standard getter
      Returns:
        Password for mailserver

    - #### setPassword

          public void setPassword(java.lang.String password)

      Sets password to authenticate at the mailserver - to be called by SmtpSampler-object
      Parameters:
        `password` - Password for mailserver

    - #### setReceiverTo

          public void setReceiverTo(java.util.List<javax.mail.internet.InternetAddress> receiverTo)

      Sets receivers of current message ("to") - to be called by SmtpSampler-object
      Parameters:
        `receiverTo` - List of receivers

    - #### getReceiverCC

          public java.util.List<javax.mail.internet.InternetAddress> getReceiverCC()

      Returns receivers of current message as `InternetAddress` ("cc") - standard getter
      Returns:
        List of receivers

    - #### setReceiverCC

          public void setReceiverCC(java.util.List<javax.mail.internet.InternetAddress> receiverCC)

      Sets receivers of current message ("cc") - to be called by SmtpSampler-object
      Parameters:
        `receiverCC` - List of receivers

    - #### getReceiverBCC

          public java.util.List<javax.mail.internet.InternetAddress> getReceiverBCC()

      Returns receivers of current message as `InternetAddress` ("bcc") - standard getter
      Returns:
        List of receivers

    - #### setReceiverBCC

          public void setReceiverBCC(java.util.List<javax.mail.internet.InternetAddress> receiverBCC)

      Sets receivers of current message ("bcc") - to be called by SmtpSampler-object
      Parameters:
        `receiverBCC` - List of receivers

    - #### isUseAuthentication

          public boolean isUseAuthentication()

      Returns if authentication is used to access the mailserver - standard getter
      Returns:
        True if authentication is used to access mailserver

    - #### setUseAuthentication

          public void setUseAuthentication(boolean useAuthentication)

      Sets if authentication should be used to access the mailserver - to be called by SmtpSampler-object
      Parameters:
        `useAuthentication` - Should authentication be used to access mailserver?

    - #### getUseSSL

          public boolean getUseSSL()

      Returns if SSL is used to send message - standard getter
      Returns:
        True if SSL is used to transmit message

    - #### setUseSSL

          public void setUseSSL(boolean useSSL)

      Sets SSL to secure the delivery channel for the message - to be called by SmtpSampler-object
      Parameters:
        `useSSL` - Should StartTLS be used to secure SMTP-connection?

    - #### getUseStartTLS

          public boolean getUseStartTLS()

      Returns if StartTLS is used to transmit message - standard getter
      Returns:
        True if StartTLS is used to transmit message

    - #### setUseStartTLS

          public void setUseStartTLS(boolean useStartTLS)

      Sets StartTLS to secure the delivery channel for the message - to be called by SmtpSampler-object
      Parameters:
        `useStartTLS` - Should StartTLS be used to secure SMTP-connection?

    - #### getSmtpPort

          public java.lang.String getSmtpPort()

      Returns port to be used for SMTP-connection (standard 25 or 465) - standard getter
      Returns:
        Port to be used for SMTP-connection

    - #### setSmtpPort

          public void setSmtpPort(java.lang.String smtpPort)

      Sets port to be used for SMTP-connection (standard 25 or 465) - to be called by SmtpSampler-object
      Parameters:
        `smtpPort` - Port to be used for SMTP-connection

    - #### isTrustAllCerts

          public boolean isTrustAllCerts()

      Returns if sampler should trust all certificates - standard getter
      Returns:
        True if all Certificates are trusted

    - #### setTrustAllCerts

          public void setTrustAllCerts(boolean trustAllCerts)

      Determines if SMTP-sampler should trust all certificates, no matter what CA - to be called by SmtpSampler-object
      Parameters:
        `trustAllCerts` - Should all certificates be trusted?

    - #### setEnforceStartTLS

          public void setEnforceStartTLS(boolean enforceStartTLS)

      Instructs object to enforce StartTLS and not to fallback to plain SMTP-connection - to be called by SmtpSampler-object
      Parameters:
        `enforceStartTLS` - Should StartTLS be enforced?

    - #### isEnforceStartTLS

          public boolean isEnforceStartTLS()

      Returns if StartTLS is enforced to secure the connection, i.e. no fallback is used (plain SMTP) - standard getter
      Returns:
        True if StartTLS is enforced

    - #### getHeaders

          public CollectionProperty getHeaders()

      Returns headers for current message - standard getter
      Returns:
        CollectionProperty of headers for current message

    - #### setHeaderFields

          public void setHeaderFields(CollectionProperty headerFields)

      Sets headers for current message
      Parameters:
        `headerFields` - CollectionProperty of headers for current message

    - #### addHeader

          public void addHeader(java.lang.String headerName,
                                java.lang.String headerValue)

      Adds a header-part to current HashMap of headers - to be called by SmtpSampler-object
      Parameters:
        `headerName` - Key for current header
        `headerValue` - Value for current header

    - #### clearHeaders

          public void clearHeaders()

      Deletes all current headers in HashMap

    - #### getAttachments

          public java.util.List<java.io.File> getAttachments()

      Returns all attachment for current message - standard getter
      Returns:
        List of attachments for current message

    - #### setAttachments

          public void setAttachments(java.util.List<java.io.File> attachments)

      Adds attachments to current message
      Parameters:
        `attachments` - List of files to be added as attachments to current message

    - #### addAttachment

          public void addAttachment(java.io.File attachment)

      Adds an attachment to current message - to be called by SmtpSampler-object
      Parameters:
        `attachment` - File-object to be added as attachment to current message

    - #### clearAttachments

          public void clearAttachments()

      Clear all attachments for current message

    - #### isSynchronousMode

          public boolean isSynchronousMode()

      Returns if synchronous-mode is used for current message (i.e. time for delivery, ... is measured) - standard getter
      Returns:
        True if synchronous-mode is used

    - #### setSynchronousMode

          public void setSynchronousMode(boolean synchronousMode)

      Sets the use of synchronous-mode (i.e. time for delivery, ... is measured) - to be called by SmtpSampler-object
      Parameters:
        `synchronousMode` - Should synchronous-mode be used?

    - #### setTimeOut

          public void setTimeOut(java.lang.String timeOut)

      Parameters:
        `timeOut` - the timeOut to set

    - #### getTimeout

          public java.lang.String getTimeout()

      Returns timeout for the SMTP-connection - returns the default timeout if no value has been supplied.
      Returns:
        Timeout to be set for SMTP-connection

    - #### setConnectionTimeOut

          public void setConnectionTimeOut(java.lang.String connectionTimeOut)

      Parameters:
        `connectionTimeOut` - the connectionTimeOut to set

    - #### getConnectionTimeout

          public java.lang.String getConnectionTimeout()

      Returns connection timeout for the SMTP-connection - returns the default connection timeout if no value has been supplied.
      Returns:
        Connection timeout to be set for SMTP-connection

    - #### setUseLocalTrustStore

          public void setUseLocalTrustStore(boolean useLocalTrustStore)

      Assigns the object to use a local truststore for SSL / StartTLS - to be called by SmtpSampler-object
      Parameters:
        `useLocalTrustStore` - Should a local truststore be used?

    - #### setTrustStoreToUse

          public void setTrustStoreToUse(java.lang.String trustStoreToUse)

      Sets the path to the local truststore to be used for SSL / StartTLS - to be called by SmtpSampler-object
      Parameters:
        `trustStoreToUse` - Path to local truststore

    - #### setUseEmlMessage

          public void setUseEmlMessage(boolean sendEmlMessage)

    - #### setEmlMessage

          public void setEmlMessage(java.lang.String emlMessage)

      Sets eml-message to be sent
      Parameters:
        `emlMessage` - path to eml-message

    - #### setMailBody

          public void setMailBody(java.lang.String body)

      Set the mail body.
      Parameters:
        `body` - the body of the mail

    - #### setPlainBody

          public void setPlainBody(boolean plainBody)

      Set whether to send a plain body (i.e. not multipart/mixed)
      Parameters:
        `plainBody` - `true` if sending a plain body (i.e. not multipart/mixed)

    - #### setEnableDebug

          public void setEnableDebug(boolean selected)

    - #### setReplyTo

          public void setReplyTo(java.util.List<javax.mail.internet.InternetAddress> replyTo)

Copyright © 1998-2018 Apache Software Foundation. All Rights Reserved.