class MailSlurpClient::FormControllerApi
Attributes
Public Class Methods
# File lib/mailslurp_client/api/form_controller_api.rb, line 19 def initialize(api_client = ApiClient.default) @api_client = api_client end
Public Instance Methods
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="api.mailslurp.com/forms" method="post" > <input name="_to" type="hidden" value="test@example.com"/> <textarea name="feedback"></textarea> <button type="submit">Submit</button> </form> “` #### URL Example “`html <form action="api.mailslurp.com/forms?_to=test@example.com" method="post" > <textarea name="feedback"></textarea> <button type="submit">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="multipart/form-data">`.
@param [Hash] opts the optional parameters @option opts [String] :_email_address Email
address of the submitting user. Include this if you wish to record the submitters email address and reply to it later. @option opts [String] :_redirect_to Optional URL to redirect form submitter to after submission. If not present user will see a success message. @option opts [String] :_spam_check 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. @option opts [String] :_subject Optional subject of the email that will be sent. @option opts [String] :_success_message Optional success message to display if no _redirectTo present. @option opts [String] :_to The email address that submitted form should be sent to. @option opts [String] :other_parameters 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. @return [String]
# File lib/mailslurp_client/api/form_controller_api.rb, line 33 def submit_form(opts = {}) data, _status_code, _headers = submit_form_with_http_info(opts) data end
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="api.mailslurp.com/forms" method="post" > <input name="_to" type="hidden" value="test@example.com"/> <textarea name="feedback"></textarea> <button type="submit">Submit</button> </form> ``` #### URL Example ```html <form action="api.mailslurp.com/forms?_to=test@example.com" method="post" > <textarea name="feedback"></textarea> <button type="submit">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="multipart/form-data">`.
@param [Hash] opts the optional parameters @option opts [String] :_email_address Email
address of the submitting user. Include this if you wish to record the submitters email address and reply to it later. @option opts [String] :_redirect_to Optional URL to redirect form submitter to after submission. If not present user will see a success message. @option opts [String] :_spam_check 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. @option opts [String] :_subject Optional subject of the email that will be sent. @option opts [String] :_success_message Optional success message to display if no _redirectTo present. @option opts [String] :_to The email address that submitted form should be sent to. @option opts [String] :other_parameters 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. @return [Array<(String, Integer, Hash)>] String data, response status code and response headers
# File lib/mailslurp_client/api/form_controller_api.rb, line 49 def submit_form_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: FormControllerApi.submit_form ...' end # resource path local_var_path = '/forms' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data', 'application/x-www-form-urlencoded']) # form parameters form_params = opts[:form_params] || {} form_params['_emailAddress'] = opts[:'_email_address'] if !opts[:'_email_address'].nil? form_params['_redirectTo'] = opts[:'_redirect_to'] if !opts[:'_redirect_to'].nil? form_params['_spamCheck'] = opts[:'_spam_check'] if !opts[:'_spam_check'].nil? form_params['_subject'] = opts[:'_subject'] if !opts[:'_subject'].nil? form_params['_successMessage'] = opts[:'_success_message'] if !opts[:'_success_message'].nil? form_params['_to'] = opts[:'_to'] if !opts[:'_to'].nil? form_params['otherParameters'] = opts[:'other_parameters'] if !opts[:'other_parameters'].nil? # http body (model) post_body = opts[:body] # return_type return_type = opts[:return_type] || 'String' # auth_names auth_names = opts[:auth_names] || ['API_KEY'] new_options = opts.merge( :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: FormControllerApi#submit_form\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end