FormControllerApi

All URIs are relative to https://api.mailslurp.com

MethodHTTP requestDescription
submitFormPOST /formsSubmit a form to be parsed and sent as an email to an address determined by the form fields

submitForm

kotlin.String submitForm(emailAddress, redirectTo, spamCheck, subject, successMessage, to, otherParameters)

Submit a form to be parsed and sent as an email to an address determined by the form fields

This endpoint allows you to submit HTML forms and receive the field values and files via email. #### Parameters The endpoint looks for special meta parameters in the form fields OR in the URL request parameters. The meta parameters can be used to specify the behaviour of the email. You must provide at-least a _to email address to tell the endpoint where the form should be emailed. These can be submitted as hidden HTML input fields with the corresponding name attributes or as URL query parameters such as ?_to=test@example.com The endpoint takes all other form fields that are named and includes them in the message body of the email. Files are sent as attachments. #### Submitting This endpoint accepts form submission via POST method. It accepts application/x-www-form-urlencoded, and multipart/form-data content-types. #### HTML Example html <form action=&quot;https://api.mailslurp.com/forms&quot; method=&quot;post&quot; > <input name=&quot;_to&quot; type=&quot;hidden&quot; value=&quot;test@example.com&quot;/> <textarea name=&quot;feedback&quot;></textarea> <button type=&quot;submit&quot;>Submit</button> </form> #### URL Example html <form action=&quot;https://api.mailslurp.com/forms?_to=test@example.com&quot; method=&quot;post&quot; > <textarea name=&quot;feedback&quot;></textarea> <button type=&quot;submit&quot;>Submit</button> </form> The email address is specified by a _to field OR is extracted from an email alias specified by a _toAlias field (see the alias controller for more information). Endpoint accepts . You can specify a content type in HTML forms using the enctype attribute, for instance: <form enctype=&quot;multipart/form-data&quot;>.

Example

// Import classes:
//import com.mailslurp.infrastructure.*
//import com.mailslurp.models.*

val apiInstance = FormControllerApi()
val emailAddress : kotlin.String = emailAddress_example // kotlin.String | Email address of the submitting user. Include this if you wish to record the submitters email address and reply to it later.
val redirectTo : kotlin.String = redirectTo_example // kotlin.String | Optional URL to redirect form submitter to after submission. If not present user will see a success message.
val spamCheck : kotlin.String = spamCheck_example // kotlin.String | Optional but recommended field that catches spammers out. Include as a hidden form field but LEAVE EMPTY. Spam-bots will usually fill every field. If the _spamCheck field is filled the form submission will be ignored.
val subject : kotlin.String = subject_example // kotlin.String | Optional subject of the email that will be sent.
val successMessage : kotlin.String = successMessage_example // kotlin.String | Optional success message to display if no _redirectTo present.
val to : kotlin.String = to_example // kotlin.String | The email address that submitted form should be sent to.
val otherParameters : kotlin.String = otherParameters_example // kotlin.String | All other parameters or fields will be accepted and attached to the sent email. This includes files and any HTML form field with a name. These fields will become the body of the email that is sent.
try {
    val result : kotlin.String = apiInstance.submitForm(emailAddress, redirectTo, spamCheck, subject, successMessage, to, otherParameters)
    println(result)
} catch (e: ClientException) {
    println("4xx response calling FormControllerApi#submitForm")
    e.printStackTrace()
} catch (e: ServerException) {
    println("5xx response calling FormControllerApi#submitForm")
    e.printStackTrace()
}

Parameters

NameTypeDescriptionNotes
emailAddresskotlin.StringEmail address of the submitting user. Include this if you wish to record the submitters email address and reply to it later.[optional]
redirectTokotlin.StringOptional URL to redirect form submitter to after submission. If not present user will see a success message.[optional]
spamCheckkotlin.StringOptional but recommended field that catches spammers out. Include as a hidden form field but LEAVE EMPTY. Spam-bots will usually fill every field. If the _spamCheck field is filled the form submission will be ignored.[optional]
subjectkotlin.StringOptional subject of the email that will be sent.[optional]
successMessagekotlin.StringOptional success message to display if no _redirectTo present.[optional]
tokotlin.StringThe email address that submitted form should be sent to.[optional]
otherParameterskotlin.StringAll other parameters or fields will be accepted and attached to the sent email. This includes files and any HTML form field with a name. These fields will become the body of the email that is sent.[optional]

Return type

kotlin.String

Authorization

Configure API_KEY: ApiClient.apiKey[“x-api-key”] = "" ApiClient.apiKeyPrefix[“x-api-key”] = ""

HTTP request headers

  • Content-Type: multipart/form-data, application/x-www-form-urlencoded
  • Accept: application/json