Creating an account with Brevo and obtaining free SMTP details for a Laravel application involves a few simple steps. This guide will walk you through the process of setting up your Brevo account, retrieving SMTP details, and configuring them in your Laravel project’s .env
file. We’ll also provide a Laravel-specific code example for sending an email, and conclude with a summary of the process.
Step 1: Creating a Brevo Account
- Visit the Brevo Website: Navigate to the official Brevo website.
- Sign Up: Find and click on the sign-up option, typically located in the top right corner of the homepage.
- Enter Your Details: Fill in your personal details such as name, email address, and create a password.
- Email Verification: Check your email inbox for a verification email from Brevo and click on the verification link.
- Log In: After verifying your email, log back into your Brevo account.
Step 2: Obtaining Free SMTP Details
- Access SMTP Settings: In your Brevo dashboard, locate the SMTP settings section.
- Enable SMTP Services: If required, request access to SMTP services and follow any additional instructions provided.
- Note SMTP Details: Once you have access, write down the SMTP details including server, port, username, and password.
Step 3: Configuring Laravel .env File
- Locate .env File: In your Laravel project directory, find the
.env
file. - Edit .env File: Open the
.env
file in your preferred text editor. - Update SMTP Details: Replace the existing SMTP details with the ones from Brevo:makefileCopy code
MAIL_MAILER=smtp MAIL_HOST=YOUR_SMTP_SERVER MAIL_PORT=YOUR_SMTP_PORT MAIL_USERNAME=YOUR_SMTP_USERNAME MAIL_PASSWORD=YOUR_SMTP_PASSWORD MAIL_ENCRYPTION=tls MAIL_FROM_ADDRESS=your.email@example.com MAIL_FROM_NAME="${APP_NAME}"
Ensure you replace YOUR_...
with the actual details you obtained from Brevo.
Save the File: After updating, save the .env
file.
Laravel Code Implementation
Here’s an example of how you can send an email in Laravel using the SMTP details:
use Illuminate\Support\Facades\Mail;
Mail::raw('This is a test email using Brevo SMTP.', function ($message) {
$message->from('your.email@example.com', 'Your Name');
$message->to('recipient@example.com');
$message->subject('Test Email');
});
Conclusion
In this guide, we’ve outlined the steps to set up a Brevo account, obtain SMTP details, and configure them in a Laravel application. The provided Laravel code snippet demonstrates how to use these SMTP settings to send an email. Integrating Brevo’s SMTP service into your Laravel application is crucial for functionalities like sending notifications, verification emails, or any other email-based communication. By following these steps, you can effectively incorporate email services into your Laravel application using Brevo’s SMTP solutions.
Leave a Reply