What Types of Email APIs Does Salesforce Provide for Programmatic Sending
According to the Salesforce Apex Outbound Email Developer Guide, Salesforce provides several programmatic interfaces for sending emails—each designed for different use cases and volume requirements:
SingleEmailMessage Handles Individual Sends with Full Customization:
Sends individual emails with full customization—HTML and text body, attachments, and custom headers. As documented in the SingleEmailMessage Class Reference, this class supports transactional and triggered emails with granular control over every message element, including sender address, reply-to settings, and activity logging.
MassEmailMessage Sends Bulk Communications Using Template-Based Delivery:
Sends emails to multiple recipients using email templates. More limited than SingleEmailMessage in customization options, but designed specifically for bulk sends where consistent template-based messaging is the priority. As detailed in the MassEmailMessage Class Reference, this class targets lead and contact IDs directly rather than arbitrary email addresses.
Messaging.sendEmail() Executes the Actual Email Transmission:
The Apex method that executes email sends by accepting arrays of email message objects. This single method handles both SingleEmailMessage and MassEmailMessage types—returning SendEmailResult objects that indicate success or failure for each message in the batch.
REST API Enables External Applications to Trigger Salesforce Email Sends:
External applications can trigger email sends via Salesforce REST API calls, enabling systems outside of Salesforce to initiate email communications that still leverage Salesforce templates, merge fields, and activity logging within the CRM.
What Sending Limits Does Salesforce Impose on API-Based Email
Salesforce imposes strict email limits on API-based sending. According to the Salesforce General Email Limits documentation, these constraints apply organization-wide and vary by edition:
Daily Single Email Limit Caps Organization-Wide Sends at 5,000:
5,000 single emails per day across the entire organization, with the count resetting at midnight GMT. This limit applies to all SingleEmailMessage sends regardless of whether they originate from Apex triggers, scheduled jobs, or manual invocations.
Mass Email Limit Restricts Bulk Sends to 5,000 External Recipients Daily:
5,000 mass emails per day to external recipients, with each MassEmailMessage call limited to 1,000 target IDs. Organizations running multiple campaigns simultaneously must carefully allocate this shared pool across all marketing initiatives.
Per-Transaction Limit Restricts sendEmail() Calls to 10 Per Apex Context:
10 sendEmail() method calls per Apex transaction, with each call accepting up to 100 messages. This governor limit means developers must batch email objects into arrays rather than calling sendEmail() inside loops—a common mistake that triggers limit exceptions.
Attachment and API Call Limits Add Additional Constraints:
Maximum attachment size and count restrictions apply per email, and every email sent consumes API calls that count against the organization’s daily API allocation—creating competition for resources between email operations and other integration processes.
Common Use Cases Where Developers Rely on Salesforce Email API
Developers use Salesforce Email API across a wide range of scenarios that require programmatic email functionality:
Triggered Emails Fire Automatically from Apex When Records Change:
Email sending from Apex triggers fires automatically when records are created or updated—such as sending a welcome email when a new lead is inserted or a confirmation when an opportunity stage changes.
Automated Sequences and Drip Campaigns Run on Scheduled Apex:
Email campaigns and drip campaigns built with scheduled Apex deliver timed message sequences—spacing emails across days or weeks based on lead stage, engagement signals, or time-based triggers.
Custom Applications Send Emails Based on User Interface Actions:
Visualforce pages or Lightning components that send emails based on user actions—such as approval confirmations, quote deliveries, or support case notifications triggered directly from custom UI elements.
Integration Workflows Bridge External Systems with Salesforce Email:
External systems triggering Salesforce emails via REST API enable scenarios where events in ERP, billing, or project management platforms initiate CRM-tracked email communications automatically.
Batch Apex Processes Large Recipient Lists Within Governor Limits:
Batch Apex jobs send mass email to large recipient lists by breaking sends into manageable chunks—each batch execution gets its own set of governor limits to process hundreds or thousands of recipients.
System Notifications Alert Users and Customers About Critical Events:
System alerts and notifications to internal users or external customers—including password resets, assignment notifications, escalation alerts, and SLA breach warnings that require immediate programmatic delivery.
SingleEmailMessage Code Example for Programmatic Email Sends
Basic Apex code for sending a single email programmatically:
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setToAddresses(new String[] {'recipient@example.com'});
email.setSubject('Your Subject');
email.setHtmlBody('
Your HTML content');email.setPlainTextBody('Plain text fallback');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });
For advanced development patterns and integration guidance, see the MassMailer Developer Guide.
What Challenges Make Direct Salesforce Email API Usage Problematic at Scale
Using Salesforce Email API directly presents significant challenges that compound as email volume grows:
Strict Daily Limits Severely Constrain Campaign Volume:
The 5,000 daily limit severely constrains email campaigns at scale. Organizations with more than a few thousand contacts find themselves rationing sends across departments—forcing marketing, sales, and operations to compete for a shared daily allocation.
Built-In Tracking Provides Minimal Engagement Visibility:
Built-in email tracking is limited. Open rates and click tracking require additional configuration beyond what the standard API provides—leaving teams without the engagement data they need to measure campaign effectiveness.
Shared IP Addresses Compromise Email Deliverability:
Shared IP addresses affect email deliverability. No dedicated IP option exists with the native API, meaning your sender reputation is influenced by every other Salesforce customer sharing the same outbound infrastructure.
Complex Error Handling Requires Extensive Custom Development:
Complex error handling is required for bounces, failures, and partial sends. The API returns results per message, but building comprehensive retry logic, bounce management, and failure notification systems demands significant custom development effort.
MassEmailMessage Template Requirements Limit Content Flexibility:
MassEmailMessage requires pre-built templates for every send, and dynamic content options within those templates are limited—preventing the kind of real-time personalization that modern email marketing demands.
Custom Development Overhead Adds Ongoing Maintenance Burden:
Custom development is required for features like scheduling, throttling, and retry logic that come standard in dedicated email platforms—creating an ongoing maintenance burden as Salesforce releases updates and governor limits evolve.
Best Practices for Working Effectively with Salesforce Email API
When using Salesforce Email API directly, follow these practices to avoid common pitfalls:
Monitor Daily Usage and Implement Limit Checks Before Every Send:
Respect limits by monitoring daily usage counters and implementing programmatic limit checks before initiating sends. The Limits class in Apex provides methods to check remaining email invocations within the current transaction context.
Inspect SendEmailResult Objects and Build Retry Logic for Failures:
Check Messaging.SendEmailResult for failures on every send and implement retry logic that handles transient errors differently from permanent failures—queuing retries for temporary issues while logging permanent bounces for data hygiene.
Use Batch Apex to Distribute Sends Across Multiple Transaction Contexts:
For large sends, use Batch Apex to manage governor limits and track progress across hundreds of execution contexts—each batch gets its own fresh set of limits while the framework handles state management between iterations.
Verify Opt-Out Status Before Every Email to Maintain Compliance:
Check opt-out status before sending every email. Respect unsubscribe preferences by querying the HasOptedOutOfEmail field on leads and contacts—ensuring compliance with CAN-SPAM, GDPR, and organizational email policies.
Enable Activity Logging to Maintain Complete Email History on Records:
Set saveAsActivity to true for tracking email history on lead, contact, and opportunity records. Activity logging creates a permanent record of every email sent through the API—providing sales reps with a complete communication history in the timeline.
Test All Email Sends in Sandbox Before Deploying to Production:
Test email sends thoroughly in sandbox environments before production deployment. Sandbox testing reveals governor limit issues, template rendering problems, and error handling gaps that would otherwise surface only in live customer communications.
How Organizations Extend Email API Capabilities Beyond Native Limits
To overcome native API limitations, organizations pursue several strategies with varying trade-offs:
AppExchange Solutions Extend Capabilities While Maintaining Native Architecture:
Native Salesforce email apps from Salesforce AppExchange extend sending capabilities while staying 100% native to the platform—preserving data residency, security model compliance, and direct access to CRM objects without external sync dependencies.
External ESPs Add Volume but Sacrifice Native Salesforce Benefits:
Integrating with external email service providers adds unlimited sending volume but loses native Salesforce benefits—introducing sync complexity, data latency, and the ongoing maintenance burden of keeping two systems aligned.
Custom Integration Callouts Require Significant Development Investment:
Building custom callouts to external sending services provides maximum flexibility but requires significant development and ongoing maintenance—including authentication management, error handling for external API failures, and data mapping between systems.
How Direct API Usage Compares to Native Salesforce Email Solutions
Comparing direct API usage to native email solutions reveals critical differences across every dimension that matters for scalable email operations:
Sending Volume: API Caps at 5,000 While Native Solutions Remove the Ceiling:
API-based sending is hard-capped at 5,000 emails per day. Native solutions bypass this constraint entirely—enabling unlimited sending without consuming API allocations or requiring workarounds like batch scheduling across multiple days.
Engagement Tracking: API Offers Basics While Native Provides Full Analytics:
API tracking is limited to basic activity logging. Native solutions include full email analytics and email metrics built in—delivering open rates, click tracking, bounce monitoring, and engagement scoring without additional configuration.
Deliverability: API Uses Shared IPs While Native Offers Dedicated Infrastructure:
API sends go through Salesforce’s shared IP pool. Native solutions provide dedicated IP addresses that you control—building sender reputation independently and eliminating the risk of deliverability damage from other tenants on shared infrastructure.
Development Effort: API Requires Custom Code While Native Uses Point-and-Click:
API-based email requires custom Apex code for every feature. Native solutions provide point-and-click configuration for sending, scheduling, templates, and automation—reducing time-to-value from weeks of development to hours of setup.
Automation: API Demands Ground-Up Development While Native Includes Built-In Workflows:
Email sending automation and follow-up sequences must be built from scratch with the API. Native solutions include pre-built automation frameworks that integrate directly with Salesforce Flow Builder, process automation, and campaign management.
Native Salesforce Solution
For organizations needing scalable email without API limitations, MassMailer operates 100% native to Salesforce—unlimited sending without consuming API limits. Complete email capabilities with Flow Builder, Apex triggers, and Process Builder integration. Use the email builder to create engaging mass email sends. Get best-in-class capabilities with dedicated IP addresses for optimal deliverability.
Key Takeaways
- Salesforce Email API provides programmatic sending via SingleEmailMessage and MassEmailMessage
- Strict limits (5,000/day) and tracking limitations constrain API-based email at scale
- Native solutions extend capabilities without API consumption or development overhead
- Consider native solutions for unlimited sending, full tracking, and dedicated IPs
Tired of wrestling with API governor limits and building custom email infrastructure from scratch? Schedule a walkthrough with our team to see how MassMailer eliminates API constraints while keeping everything 100% native to Salesforce—no custom code, no sync headaches, no daily sending caps.