I'm looking to send emails through the REST API, specifically through Restforce in Ruby, but I can't find any resources on this. I am finding my resources about the sendEmail function, and how to set this up in Apex, but nothing about sending an email through the REST API.

Is it possible to send an email via the REST API, and if so, how would I do so?

  • 1
    i think we can have an apex class with http annotation built for this as this send email is not supported in REST! Commented Sep 26, 2013 at 17:05

3 Answers 3


You can create a REST service (using the appropriate annotations) to accept an email via REST and send it through that interface. Brief example here:

global class SendEmailController {
    global static String doPost() {
        String result = 'error: email not sent';
        try {
            // send email here
            result = 'success: email sent successfully';
        } catch(Exception e) {

        return result;

You'll be subject to the 1000 per day email limit, though, so you might consider an alternative means of sending emails (like, from your domain's MTA, if configured correctly).


With Salesforce Actions, you can use the REST api to send emails that count against the "DailyWorkflowEmails" limit instead of the "SingleEmail" limit, which is usually significantly larger. This functionality became available with api 32.0.

$ curl -H 'Authorization: Bearer SessionId' -H 'X-PrettyPrint:1' -H 'Content-Type: application/json' -d @jsonfile BaseURL/services/data/v36.0/actions/standard/emailSimple


  "inputs" : [
      "emailBody" : "This is the body of the email",
      "emailAddresses" : "[email protected],[email protected]",
      "emailSubject" : "An email from salesforce",
      "senderType" : "CurrentUser"

yes you can below is php function which uses rest api to send email to use this you will need to register and get keys https://www.sakshamappinternational.com/sakshamapp-es/

function cURLSakshamappESEmail($to_name,$to_email, $subject, $body_text, $body_html, $from_name, $from_email) {

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, 'http://app.sakshamapp.com/api_call/v1/transactional_emails.php');
    curl_setopt($ch, CURLOPT_POST, 1);

    $data = 'ses_publicKey='.urlencode(get_option('ses_publicKey')).

    if($body_html)  $data .= '&body_html='.urlencode($body_html);
    if($body_text)  $data .= '&body_text='.urlencode($body_text);

    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

        $header = "Content-Type: application/x-www-form-urlencoded\r\n";
        $header .= "Content-Length: ".strlen($data)."\r\n\r\n";

    $result = curl_exec($ch);


     global $wpdb;

        'from_email' => $from_email,
        'from_name'  => $from_name,
        'to_name'  => $to_name,
        'to_email'  => $to_email,
        'subject'  => $subject,
        'status'  => $result 

    return ($result === false) ? NULL : $result;

  • This is nothing to do with standard REST API provided by Salesforce out of the box. Commented Oct 8, 2017 at 19:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .