# /send-form

Sends an email based on the specified email template and the passed form data. The email is sent via the specified email service or via the default service if "default_service" is passed.

# Resource URL

POST https://api.emailjs.com/api/v1.0/email/send-form

# Request Information

Content type is 'multipart/form-data'

# Rate Limit

1 request per second

# Parameters

NAME REQUIRED DESCRIPTION
service_id Yes Service ID of the service through which the email should be sent. Reserved keyword 'default_service' is supported, and should be used to use the default service, which can be set and changed via EmailJS dashboard.
template_id Yes Template ID of the email
user_id Yes User ID of the account

# Response Information

Response formats is JSON or Text

# Example Response

Success status:

200 "OK"

Failure status:

400 "The user_id parameter is required"

# Code Example

For this example we will use jQuery library. It has ajax and supports very old browsers.

// code fragment
// the form id is myForm
$('#myForm').on('submit', function(event) {
    event.preventDefault(); // prevent reload
    
    var formData = new FormData(this);
    formData.append('service_id', 'YOUR_SERVICE_ID');
    formData.append('template_id', 'YOUR_TEMPLATE_ID');
    formData.append('user_id', 'YOUR_USER_ID');
 
    $.ajax('https://api.emailjs.com/api/v1.0/email/send-form', {
        type: 'POST',
        data: formData,
        contentType: false, // auto-detection
        processData: false // no need to parse formData to string
    }).done(function() {
        alert('Your mail is sent!');
    }).fail(function(error) {
        alert('Oops... ' + JSON.stringify(error));
    });
});
// code fragment