Skip to main content

Prerequisites

To get the most out of this guide, you’ll need to:
You can find your API keys in your SendPost Dashboard. Make sure to use your Sub-Account API Key for sending emails.

1. Install Dependencies

composer

2. Environment Setup

Add to your .env file:

3. Create SendPost Mail Driver

Create app/Mail/Drivers/SendPostTransport.php:
PHP

4. Register Mail Driver

Add to app/Providers/AppServiceProvider.php:
PHP
Add to config/services.php:
PHP
Update config/mail.php:
PHP

5. Send Your First Email

Using Mail Facade

PHP

Using Mailable Class

Create a mailable:
Update app/Mail/WelcomeEmail.php:
PHP
Create resources/views/emails/welcome.blade.php:
Blade
Send the email:
PHP

6. Common Use Cases

Password Reset Email

Create app/Mail/PasswordResetEmail.php:
PHP
Create resources/views/emails/password-reset.blade.php:
Blade

Order Confirmation Email

Create app/Mail/OrderConfirmation.php:
PHP

7. Using Notifications

Create a notification:
Update app/Notifications/WelcomeNotification.php:
PHP
Send notification:
PHP

8. Personalization with Custom Fields

Create a custom mailable with personalization:
PHP

9. Direct API Usage (Alternative)

Create app/Services/SendPostService.php:
PHP
Use the service:
PHP
Make sure your sender email domain is verified in your SendPost account before sending emails.

10. Next Steps

Explore more examples and use cases:

Laravel Documentation

Learn more about Laravel framework

SendPost PHP SDK

View the official SDK on GitHub

Quickstart Example

View a complete working example on GitHub