rapidrx/intelmail

A Laravel package to test email services using the Mailtrap API. This package allows developers to send test emails through Mailtrap's sandbox environment, ensuring email functionality works correctly in a development setting.

1.1.6 2024-06-24 21:54 UTC

This package is auto-updated.

Last update: 2024-10-24 22:43:59 UTC


README

This package allows you to test email functionalities in a development environment using the Mailtrap API. Follow the steps below to configure the package, set up your environment, and send test emails.

INSTALLATION

composer require --dev rapidrx/intelmail

CONFIGURATION

  1. Signup for Mailtrap

    • Go to Mailtrap.
    • Sign up using Google Authentication or create an account manually.
  2. Configure Mailtrap SMTP Settings

    • After logging in, navigate to the Inbox section.
    • Go to Integration and then Credentials.
    • Copy the SMTP credentials provided and add them to your .env file:
      MAIL_MAILER=smtp
      MAIL_HOST=sandbox.smtp.mailtrap.io
      MAIL_PORT=2525
      MAIL_USERNAME=your_username
      MAIL_PASSWORD=your_password
  3. Configure Mailtrap API Settings

    • In your Mailtrap account, navigate to Inbox -> Integration -> API.
    • Copy the necessary API details and add them to your .env file:
      INTEL_MAIL_BASE_URL=your_base_url
      INTELMAIL_AUTHORIZATION=your_authorization_token
      INTEL_MAIL_FROM_NAME=your_from_name
      INTEL_MAIL_TO=recipient_email_address

How to Send a Test Email

To send a test email using the Laravel package, use the following code snippet. This example demonstrates sending an email with an HTML body and an attachment:

SENDING EMAIL

IntelMail::post([
    'subject' => 'Test Email',
    'body_type' => 'html',
    'html_view' => 'welcome',
]);

SENDING EMAIL WITH ATTACHMENT

IntelMail::post([
    'subject' => 'Test Email',
    'body_type' => 'html',
    'html_view' => 'welcome',
    'attachment' => [
        [
            'content' => base64_encode(file_get_contents(storage_path('app/public/file.txt'))),
            'filename' => 'file.txt',
            'type' => mime_content_type(storage_path('app/public/file.txt')),
        ]
    ]
]);