Laravel Email Testing with Sendria in Software Development Company

Posted by Jessica Bennett
7
Jun 24, 2024
129 Views

Adding reliable email functionality while building applications with Laravel is crucial for a software development company. This ensures emails are delivered correctly and formatted flawlessly, enhancing engagement and application success.

This guide discusses Laravel email testing with Sendria and provides step-by-step instructions. So, keep scrolling through.

Know about Sendria

Sendria (formerly MailTrap) is an open-source project (ref https://github.com/msztolcman/sendria). It makes testing emails locally in a Laravel application easy. It's a developer-focused tool designed to streamline the testing process for applications built with various frameworks. Unlike traditional email providers, Sendria acts as a secure catch-all for emails sent during development. Here's what makes it stand out:

Safe testing environment: Sendria prevents development emails from reaching real users. All emails sent through the application during testing are captured within Sendria's web interface, eliminating the risk of accidentally bombarding users with test messages.

Effortless integration: Setting up Sendria is a breeze. It integrates seamlessly with popular development environments, allowing developers to configure the application to send emails to Sendria's servers instead of external providers.

Detailed inspection: Sendria empowers developers to dissect the development emails with ease. Its web interface provides a clear overview of all captured emails, allowing developers to inspect content, headers, and attachments. This meticulous examination ensures emails are formatted correctly and meet the application's requirements.

Collaboration made easy: Working with a development team? Sendria facilitates collaboration by making captured emails readily accessible to all team members. This advocates transparency and ensures every team member is on the same page regarding email functionality.

Sendria package installation in a software development company

Reliable custom software development solutions include Sendria package installation with the following steps:

Python environment: Ensure Python 3.7+ is installed. Verify with:

python3 --version

Install Sendria: Use pip for installation.

python3 -m pip install sendria

Run Sendria: Start the Sendria server with:

sendria --db mails.sqlite

Configure Laravel: Update Laravel's mail.php configuration:

return [
    'driver' => env('MAIL_DRIVER', 'smtp'),
    'host' => env('MAIL_HOST', '127.0.0.1'),
    'port' => env('MAIL_PORT', 1025),
    'from' => [
        'address' => env('MAIL_FROM_ADDRESS', 'example@example.com'),
        'name' => env('MAIL_FROM_NAME', 'Example'),
    ],
    'encryption' => env('MAIL_ENCRYPTION', null),
    'username' => env('MAIL_USERNAME', null),
    'password' => env('MAIL_PASSWORD', null),
    'sendmail' => '/usr/sbin/sendmail -bs',
    'markdown' => [
        'theme' => 'default',
        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],
];

Environment variables: Set the environment variables in .env:

MAIL_MAILER=smtp
MAIL_HOST=127.0.0.1
MAIL_PORT=1025
MAIL_FROM_ADDRESS=example@example.com
MAIL_FROM_NAME="${APP_NAME}"

Send test email: Use Laravel's built-in email testing capabilities:

use Illuminate\Support\Facades\Mail;

Mail::raw('Test email', function ($message) {
   $message->to('recipient@example.com')
            ->subject


Comments
avatar
Please sign in to add comment.