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
Requires
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
-
Signup for Mailtrap
- Go to Mailtrap.
- Sign up using Google Authentication or create an account manually.
-
Configure Mailtrap SMTP Settings
- After logging in, navigate to the
Inbox
section. - Go to
Integration
and thenCredentials
. - 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
- After logging in, navigate to the
-
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
- In your Mailtrap account, navigate to
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')), ] ] ]);